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

Unified Diff: src/collection-iterator.js

Issue 355663002: Optimize Map/Set.prototype.forEach (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Also get rid of NewIteratorResultObject since there are no more users of it 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 | « src/collection.js ('k') | src/factory.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/collection-iterator.js
diff --git a/src/collection-iterator.js b/src/collection-iterator.js
index 2436a931e28bc4acde80f5c4a8143cc0bff5b8f3..323786b28cc2704b699541f1cfcf5e953ba12ac4 100644
--- a/src/collection-iterator.js
+++ b/src/collection-iterator.js
@@ -21,7 +21,24 @@ function SetIteratorNextJS() {
throw MakeTypeError('incompatible_method_receiver',
['Set Iterator.prototype.next', this]);
}
- return %SetIteratorNext(this);
+
+ var value_array = [UNDEFINED, UNDEFINED];
+ var entry = {value: value_array, done: false};
arv (Not doing code reviews) 2014/06/25 20:17:54 I benchmarked this and the following code has no n
+ switch (%SetIteratorNext(this, value_array)) {
+ case 0:
+ entry.value = UNDEFINED;
+ entry.done = true;
+ break;
+ case ITERATOR_KIND_VALUES:
+ entry.value = value_array[0];
+ break;
+ case ITERATOR_KIND_ENTRIES:
+ value_array[1] = value_array[0];
+ entry.value = value_array;
+ break;
+ }
+
+ return entry;
}
@@ -97,7 +114,26 @@ function MapIteratorNextJS() {
throw MakeTypeError('incompatible_method_receiver',
['Map Iterator.prototype.next', this]);
}
- return %MapIteratorNext(this);
+
+ var value_array = [UNDEFINED, UNDEFINED];
+ var entry = {value: value_array, done: false};
+ switch (%MapIteratorNext(this, value_array)) {
+ case 0:
+ entry.value = UNDEFINED;
+ entry.done = true;
+ break;
+ case ITERATOR_KIND_KEYS:
+ entry.value = value_array[0];
+ break;
+ case ITERATOR_KIND_VALUES:
+ entry.value = value_array[1];
+ break;
+ case ITERATOR_KIND_ENTRIES:
+ entry.value = value_array;
+ break;
+ }
+
+ return entry;
}
« no previous file with comments | « src/collection.js ('k') | src/factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698