-
Notifications
You must be signed in to change notification settings - Fork 277
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Iterating over fast arrays currently is 2.5x slower than it should be. Example:
for (const x of [1,2,3]) print(x)It goes through the whole rigamarole of:
- invoking
[Symbol.iterator]() - creating an iterator object
iter - repeatedly invoking
iter.next()until it's exhausted
For fast arrays, all three steps are pure overhead.
A fast array fast path is in principle easy to implement except for the perennial problem of mutation while iterating. Maybe track the array's JSShape and bail out if it changes?
Bailing out can be done by calling js_create_array_iterator() and updating it->idx to the current index.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request