[webkit-dev] Style: Vector::iterator vs indexed iteration
Ryosuke Niwa
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?
- Ryosuke
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
> http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20111017/49b5fd21/attachment.html>
More information about the webkit-dev
mailing list