[Libreoffice] faster stl prefix iterators ...
Michael Meeks
michael.meeks at novell.com
Mon Nov 29 02:34:16 PST 2010
On Sat, 2010-11-27 at 21:02 +0000, Caolán McNamara wrote:
> As Takeshi pointed out in another mail, the postfix form returns a copy
> of the iterator as it was before the increment, while the prefix form
> returns a reference to the current value after its increment. So postfix
> requires an extra copy which makes it inherently slower.
Oh nice; not something I had noticed. Can we do a big global hunt & fix
for all these instances ?
> I'm not so sure that compilers can optimize STL postfix operators with
> the ease they do for basic types. Their implementation differs quite a
> bit from one impl to another.
Quite; optimising LO's C++ is quite excitingly limited in many ways
(often by the low-level C API impls eg.).
> Anyway, I reckon its worth tackling the cppcheck warnings about the
> postfix operator being used where a prefix would suffice.
Yes - would be wonderful to have a "fix this entire class of problem"
approach to the code-base; to win the performance & size improvement
everywhere - and to make the patch easy to review too I guess ;-)
Interesting,
Michael.
--
michael.meeks at novell.com <><, Pseudo Engineer, itinerant idiot
More information about the LibreOffice
mailing list