Closed Bug 1380111 Opened 9 years ago Closed 9 years ago

Inline iterator code into Map/Set.prototype.forEach

Categories

(Core :: JavaScript: Standard Library, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla56
Tracking Status
firefox56 --- fixed

People

(Reporter: anba, Assigned: anba)

Details

Attachments

(1 file, 1 obsolete file)

With bug 1380087, this patch seems to improve Map.prototype.forEach quite a bit. Improves from 480ms (tip) to 150ms: var m = new Map(Array(100).fill(0).map((v, k) => [k + 1, null])); var q = 0; function fn(v, k) { q += k; } var t = Date.now(); for (var i = 0; i < 100000; ++i) { m.forEach(fn); } print([Date.now() - t, q); Improves from 160ms (bug 1380087) to 130ms for me: var s = new Set(Array(100).fill(0).map((v, k) => k + 1)); var q = 0; function fn() { ++q; } var t = Date.now(); for (var i = 0; i < 100000; ++i) { s.forEach(fn); } print(Date.now() - t, q);
Attached patch bug1380111.patch (obsolete) — Splinter Review
Attachment #8885418 - Flags: review?(till)
Comment on attachment 8885418 [details] [diff] [review] bug1380111.patch Review of attachment 8885418 [details] [diff] [review]: ----------------------------------------------------------------- Nice, r=me ::: js/src/builtin/Set.js @@ +37,5 @@ > var values = callFunction(std_Set_iterator, S); > + > + // Inlined: SetIteratorNext > + var setIterationResult = setIteratorTemp.setIterationResult; > + if (!setIterationResult) { style nit: no braces needed
Attachment #8885418 - Flags: review?(till) → review+
Attached patch bug1380111.patchSplinter Review
Addressed review comments, carrying r+.
Attachment #8885418 - Attachment is obsolete: true
Attachment #8885835 - Flags: review+
Pushed by ryanvm@gmail.com: https://hg.mozilla.org/integration/mozilla-inbound/rev/bed95eec1188 Inline iterator code into Map/Set forEach to avoid extra allocations. r=till
Keywords: checkin-needed
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla56
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: