[webkit-dev] Style: Vector::iterator vs indexed iteration
darin at apple.com
Mon Oct 17 16:25:28 PDT 2011
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.
More information about the webkit-dev