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

Side by Side Diff: src/harmony-array.js

Issue 856303002: Don't take iterable path in ArrayFrom if items[@@iterator] is null (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 11 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 | « no previous file | src/v8natives.js » ('j') | src/v8natives.js » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 'use strict'; 5 'use strict';
6 6
7 // This file relies on the fact that the following declaration has been made 7 // This file relies on the fact that the following declaration has been made
8 // in runtime.js: 8 // in runtime.js:
9 // var $Array = global.Array; 9 // var $Array = global.Array;
10 10
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 if (mapping) { 135 if (mapping) {
136 if (!IS_SPEC_FUNCTION(mapfn)) { 136 if (!IS_SPEC_FUNCTION(mapfn)) {
137 throw MakeTypeError('called_non_callable', [ mapfn ]); 137 throw MakeTypeError('called_non_callable', [ mapfn ]);
138 } else if (IS_NULL_OR_UNDEFINED(receiver)) { 138 } else if (IS_NULL_OR_UNDEFINED(receiver)) {
139 receiver = %GetDefaultReceiver(mapfn) || receiver; 139 receiver = %GetDefaultReceiver(mapfn) || receiver;
140 } else if (!IS_SPEC_OBJECT(receiver) && %IsSloppyModeFunction(mapfn)) { 140 } else if (!IS_SPEC_OBJECT(receiver) && %IsSloppyModeFunction(mapfn)) {
141 receiver = ToObject(receiver); 141 receiver = ToObject(receiver);
142 } 142 }
143 } 143 }
144 144
145 var iterable = ToIterable(items); 145 var iterable = GetMethod(items, symbolIterator);
arv (Not doing code reviews) 2015/01/21 15:05:18 We now call items.[[Get]](symbolIterator) twice. T
caitp (gmail) 2015/01/21 17:21:49 hmm, well it's trivial to replace the for...of wit
146 var k; 146 var k;
147 var result; 147 var result;
148 var mappedValue; 148 var mappedValue;
149 var nextValue; 149 var nextValue;
150 150
151 if (!IS_UNDEFINED(iterable)) { 151 if (!IS_UNDEFINED(iterable)) {
152 result = %IsConstructor(this) ? new this() : []; 152 result = %IsConstructor(this) ? new this() : [];
153 153
154 k = 0; 154 k = 0;
155 for (nextValue of items) { 155 for (nextValue of items) {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 215
216 // Set up the non-enumerable functions on the Array prototype object. 216 // Set up the non-enumerable functions on the Array prototype object.
217 InstallFunctions($Array.prototype, DONT_ENUM, $Array( 217 InstallFunctions($Array.prototype, DONT_ENUM, $Array(
218 "find", ArrayFind, 218 "find", ArrayFind,
219 "findIndex", ArrayFindIndex, 219 "findIndex", ArrayFindIndex,
220 "fill", ArrayFill 220 "fill", ArrayFill
221 )); 221 ));
222 } 222 }
223 223
224 HarmonyArrayExtendArrayPrototype(); 224 HarmonyArrayExtendArrayPrototype();
OLDNEW
« no previous file with comments | « no previous file | src/v8natives.js » ('j') | src/v8natives.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698