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

Unified Diff: src/collection.js

Issue 1155893003: Add {Map,Set}::FromArray to the API (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 7 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
« include/v8.h ('K') | « src/bootstrapper.cc ('k') | src/contexts.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 eddf0f32655f1ed0be27c2a496c2a803e09d4391..00a14aa77c1347592d0f8481da4c5b0d4b410f6f 100644
--- a/src/collection.js
+++ b/src/collection.js
@@ -2,6 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+var $mapFromArray;
+var $setFromArray;
+
(function(global, shared, exports) {
"use strict";
@@ -437,4 +440,23 @@ $installFunctions(GlobalMap.prototype, DONT_ENUM, [
"forEach", MapForEach
]);
+$mapFromArray = function(array) {
+ var map = new GlobalMap;
+ var length = array.length;
+ for (var i = 0; i < length; ++i) {
+ var entry = array[i];
+ %_CallFunction(map, entry[0], entry[1], MapSet);
+ }
+ return map;
+}
arv (Not doing code reviews) 2015/05/26 16:37:40 ;
adamk 2015/05/26 17:27:45 Done.
+
+$setFromArray = function(array) {
+ var set = new GlobalSet;
+ var length = array.length;
+ for (var i = 0; i < length; ++i) {
+ %_CallFunction(set, array[i], SetAdd);
+ }
+ return set;
+}
arv (Not doing code reviews) 2015/05/26 16:37:40 ;
adamk 2015/05/26 17:27:45 Done.
+
})
« include/v8.h ('K') | « src/bootstrapper.cc ('k') | src/contexts.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698