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: Rebased 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
« no previous file with comments | « 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 6b468f5fc0ee8b2de8cd61ca1a27e4c78c8dcfb5..1c6b475df6cf4761f4d25738150b1d3bfa3c44d5 100644
--- a/src/collection.js
+++ b/src/collection.js
@@ -4,6 +4,8 @@
var $getHash;
var $getExistingHash;
+var $mapFromArray;
+var $setFromArray;
(function(global, utils) {
"use strict";
@@ -480,4 +482,23 @@ utils.InstallFunctions(GlobalMap.prototype, DONT_ENUM, [
$getHash = GetHash;
$getExistingHash = GetExistingHash;
+$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;
+};
+
+$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;
+};
+
})
« no previous file with comments | « src/bootstrapper.cc ('k') | src/contexts.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698