About replacing some "C-Array" into std::array

julien2412 serval2412 at yahoo.fr
Fri Nov 22 15:31:23 UTC 2019


Hello,

Taking a look at cppcheck report, I noticed this kind of reports:
vcl/source/treelist/transfer.cxx
132	useStlAlgorithm	398	style	Consider using std::fill algorithm instead of
a raw loop

To use std::fill, we'd need to convert the C array into std::array.
Reading https://coders-corner.net/2018/06/16/stdarray-vs-c-style-array/, it
seems there's no real cons about this.

The idea is not only to diminish cppcheck reports but above all try to gain
some perfs (even little but multiplied by the number of calls...) by using
STL. Since we're at the beginning of 6.5, thought it could be relevant.
The code change should be quite straight forward, so risk of regression
should be low.

Is there some kind of rule of thumb to decide between C array and std::array
?
Any thoughts?

Julien
PS : I focused on std::fill but there are other STL related reports by
cppcheck, "std::find_if", "std::count_if", "std::generate", etc.



--
Sent from: http://document-foundation-mail-archive.969070.n3.nabble.com/Dev-f1639786.html


More information about the LibreOffice mailing list