Summary: | Switch List to Vector (.5% speedup) | ||||||
---|---|---|---|---|---|---|---|
Product: | WebKit | Reporter: | Geoffrey Garen <ggaren> | ||||
Component: | JavaScriptCore | Assignee: | Geoffrey Garen <ggaren> | ||||
Status: | RESOLVED FIXED | ||||||
Severity: | Normal | ||||||
Priority: | P2 | ||||||
Version: | 523.x (Safari 3) | ||||||
Hardware: | Mac | ||||||
OS: | OS X 10.4 | ||||||
Attachments: |
|
Description
Geoffrey Garen
2007-11-04 15:49:14 PST
Created attachment 17039 [details]
Patch
Comment on attachment 17039 [details]
Patch
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.) Changeset 27448. |