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

Side by Side Diff: src/collection.js

Issue 1157843006: Flatten the Arrays returned and consumed by the v8::Map API (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Reject FromArray args with odd lengths Created 5 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 unified diff | Download patch
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; 7 var $mapFromArray;
8 var $setFromArray; 8 var $setFromArray;
9 9
10 (function(global, utils) { 10 (function(global, utils) {
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 "forEach", MapForEach 478 "forEach", MapForEach
479 ]); 479 ]);
480 480
481 // Expose to the global scope. 481 // Expose to the global scope.
482 $getHash = GetHash; 482 $getHash = GetHash;
483 $getExistingHash = GetExistingHash; 483 $getExistingHash = GetExistingHash;
484 484
485 $mapFromArray = function(array) { 485 $mapFromArray = function(array) {
486 var map = new GlobalMap; 486 var map = new GlobalMap;
487 var length = array.length; 487 var length = array.length;
488 for (var i = 0; i < length; ++i) { 488 for (var i = 0; i < length; i += 2) {
489 var entry = array[i]; 489 var key = array[i];
490 %_CallFunction(map, entry[0], entry[1], MapSet); 490 var value = array[i + 1];
491 %_CallFunction(map, key, value, MapSet);
491 } 492 }
492 return map; 493 return map;
493 }; 494 };
494 495
495 $setFromArray = function(array) { 496 $setFromArray = function(array) {
496 var set = new GlobalSet; 497 var set = new GlobalSet;
497 var length = array.length; 498 var length = array.length;
498 for (var i = 0; i < length; ++i) { 499 for (var i = 0; i < length; ++i) {
499 %_CallFunction(set, array[i], SetAdd); 500 %_CallFunction(set, array[i], SetAdd);
500 } 501 }
501 return set; 502 return set;
502 }; 503 };
503 504
504 }) 505 })
OLDNEW
« src/api.cc ('K') | « src/api.cc ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698