STL iterators and for loops

Stephan Bergmann sbergman at redhat.com
Fri Feb 28 01:06:33 PST 2014


On 02/28/2014 06:42 AM, Tor Lillqvist wrote:
>> My builds with --enable-dbgutil are noticeably slow,
>> OTOH, hoisting vec.end() so
>> that is is called only once should be a quite mechanical task,
>
> Mechanical tasks are typically those where it is very easy to miss
> some crucial detail in some case and introduce a bug.

...like cases that purposefully keep re-evaluating end() because it gets 
invalidated in the loop's body.

Also, hoisting the variable typically doesn't make the code more 
readable, and all this will eventually become moot with C++11 anyway.

Stephan


More information about the LibreOffice mailing list