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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « src/bootstrapper.cc ('k') | src/contexts.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 var $getHash; 5 var $getHash;
6 var $getExistingHash; 6 var $getExistingHash;
7 var $mapFromArray;
8 var $setFromArray;
7 9
8 (function(global, utils) { 10 (function(global, utils) {
9 "use strict"; 11 "use strict";
10 12
11 %CheckIsBootstrapping(); 13 %CheckIsBootstrapping();
12 14
13 // ------------------------------------------------------------------- 15 // -------------------------------------------------------------------
14 // Imports 16 // Imports
15 17
16 var GlobalMap = global.Map; 18 var GlobalMap = global.Map;
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 "has", MapHas, 475 "has", MapHas,
474 "delete", MapDelete, 476 "delete", MapDelete,
475 "clear", MapClearJS, 477 "clear", MapClearJS,
476 "forEach", MapForEach 478 "forEach", MapForEach
477 ]); 479 ]);
478 480
479 // Expose to the global scope. 481 // Expose to the global scope.
480 $getHash = GetHash; 482 $getHash = GetHash;
481 $getExistingHash = GetExistingHash; 483 $getExistingHash = GetExistingHash;
482 484
485 $mapFromArray = function(array) {
486 var map = new GlobalMap;
487 var length = array.length;
488 for (var i = 0; i < length; ++i) {
489 var entry = array[i];
490 %_CallFunction(map, entry[0], entry[1], MapSet);
491 }
492 return map;
493 };
494
495 $setFromArray = function(array) {
496 var set = new GlobalSet;
497 var length = array.length;
498 for (var i = 0; i < length; ++i) {
499 %_CallFunction(set, array[i], SetAdd);
500 }
501 return set;
502 };
503
483 }) 504 })
OLDNEW
« 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