Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1185)

Unified Diff: src/collection.js

Issue 329253004: Optimize Map/Set.prototype.forEach (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Update count to fix merge issue Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/objects.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/collection.js
diff --git a/src/collection.js b/src/collection.js
index 0d8dd77f7bd3be944ffcd25b51544d8ebe740c00..ca31152d89d5a5410f2f24203872269d9b9441c1 100644
--- a/src/collection.js
+++ b/src/collection.js
@@ -80,11 +80,13 @@ function SetForEach(f, receiver) {
}
var iterator = new SetIterator(this, ITERATOR_KIND_VALUES);
- var entry;
+ var key;
var stepping = %_DebugCallbackSupportsStepping(f);
- while (!(entry = %SetIteratorNext(iterator)).done) {
+ while (%SetIteratorHasMore(iterator)) {
+ key = %SetIteratorCurrentKey(iterator);
+ %SetIteratorMoveNext(iterator);
Michael Starzinger 2014/06/23 19:51:52 I am _very_ surprised that this is faster. How are
arv (Not doing code reviews) 2014/06/23 20:31:51 The cost of 1 call vs 3 calls is not so large. Sin
if (stepping) %DebugPrepareStepInIfStepping(f);
- %_CallFunction(receiver, entry.value, entry.value, this, f);
+ %_CallFunction(receiver, key, key, this, f);
}
}
@@ -191,17 +193,21 @@ function MapForEach(f, receiver) {
}
var iterator = new MapIterator(this, ITERATOR_KIND_ENTRIES);
- var entry;
+ var key, value;
var stepping = %_DebugCallbackSupportsStepping(f);
- while (!(entry = %MapIteratorNext(iterator)).done) {
+ while (%MapIteratorHasMore(iterator)) {
+ key = %MapIteratorCurrentKey(iterator);
+ value = %MapIteratorCurrentValue(iterator);
+ %MapIteratorMoveNext(iterator);
if (stepping) %DebugPrepareStepInIfStepping(f);
- %_CallFunction(receiver, entry.value[1], entry.value[0], this, f);
+ %_CallFunction(receiver, value, key, this, f);
}
}
// -------------------------------------------------------------------
+
function SetUpMap() {
%CheckIsBootstrapping();
« no previous file with comments | « no previous file | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698