Re: Performance: Iterating a vector in a loop..



"andré m.a" <a.m.a@xxxxxxxxxxxx> wrote in message
news:YArle.5230$8j3.220242@xxxxxxxxxxxxxxxxxxxxxx
>
> and im not sure if
>
> while( itLoop != itEnd )
> {
> (++itLoop)->DoSomething();
> }
>
> would be faster either.

since 'for' is more or less a bit of syntactic sugar for 'while', it would
more than likely be faster, since here you are missing off the first element
of the collection, so you're doing one iteration. of course, if itLoop ==
end() on entry to the loop, you have undefined behavior.

You'd need to use a post-increment or put the pre-increment after the call
to DoSomething.

S.


.