Bug 15835 - Switch List to Vector (.5% speedup)
Summary: Switch List to Vector (.5% speedup)
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 523.x (Safari 3)
Hardware: Mac OS X 10.4
: P2 Normal
Assignee: Geoffrey Garen
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-11-04 15:49 PST by Geoffrey Garen
Modified: 2007-11-05 13:47 PST (History)
0 users

See Also:


Attachments
Patch (29.38 KB, patch)
2007-11-04 15:49 PST, Geoffrey Garen
darin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Geoffrey Garen 2007-11-04 15:49:14 PST
Patch coming.
Comment 1 Geoffrey Garen 2007-11-04 15:49:30 PST
Created attachment 17039 [details]
Patch
Comment 2 Darin Adler 2007-11-04 16:44:33 PST
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")
Comment 3 Eric Seidel (no email) 2007-11-05 13:42:22 PST
Nice!  Sad it was so little...
Comment 4 Geoffrey Garen 2007-11-05 13:47:05 PST
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.)
Comment 5 Geoffrey Garen 2007-11-05 13:47:32 PST
Changeset 27448.