Created attachment 17039 [details]
Comment on attachment 17039 [details]
The best idiom for iterating a vector is to use indices and not bother with iterator objects at all. I believe it's faster than the iterator version, and certainly more readable!
But for speed, you'd want a version that doesn't do a range check each time.
r=me (as is -- those comments above are "food for thought")
Nice! Sad it was so little...
Committed revision 27448.
Iteration by index would certainly be more readable. I think we could do that if we made "return undefined if I'm past the end" a special-case function instead of the default behavior of operator. (Hopefully we could do that without introducing subtle regressions!)
Still, I worry that iteration by index might be slightly slower, based on this check-in by Maciej: http://trac.webkit.org/projects/webkit/changeset/27339. It seems like using a pointer directly into the VectorBuffer can be faster than using an integer offset into the Vector, which translates into a pointer into the VectorBuffer. (Maybe the compiler can optimize that translation out, though.)