[webkit-dev] Style: Vector::iterator vs indexed iteration
rniwa at webkit.org
Mon Oct 17 16:30:57 PDT 2011
Thanks for the clarification, Darin.
Can we add this preference on the style guide for the future reference?
On Mon, Oct 17, 2011 at 4:25 PM, Darin Adler <darin at apple.com> wrote:
> We prefer index style. In the past I believe we could not measure a
> difference in performance.
> One benefit of the index style is that it is more terse, and often easier
> to read than the iterator style, which requires repeating the type name
> twice to declare the start and end value of the vector.
> Another benefit of the index style is that it behaves predictably if
> elements are added to the vector while iterating it. The pointer style can
> easily end up accessing freed memory.
> A benefit of the pointer style is that it could theoretically be faster
> because there is no need to refetch the vector base address.
> -- Darin
> webkit-dev mailing list
> webkit-dev at lists.webkit.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the webkit-dev