Chromium Code Reviews| Index: src/js/array.js |
| diff --git a/src/js/array.js b/src/js/array.js |
| index da6e02ededdcd7bd79dc53ff04dfaa05040c5719..f7f419ec652c9f42ed9b0909b3efd97a5cc6ac85 100644 |
| --- a/src/js/array.js |
| +++ b/src/js/array.js |
| @@ -1776,23 +1776,10 @@ function ArrayFrom(arrayLike, mapfn, receiver) { |
| if (!IS_UNDEFINED(iterable)) { |
| result = %IsConstructor(this) ? new this() : []; |
| - |
| - var iterator = GetIterator(items, iterable); |
| - |
| k = 0; |
| - while (true) { |
| - var next = iterator.next(); |
| - |
| - if (!IS_RECEIVER(next)) { |
| - throw MakeTypeError(kIteratorResultNotAnObject, next); |
| - } |
| - if (next.done) { |
| - result.length = k; |
| - return result; |
| - } |
| - |
| - nextValue = next.value; |
| + for (nextValue of |
| + { [iteratorSymbol]() { return %_Call(iterable, items) } }) { |
|
neis
2016/02/10 08:38:28
Is there a good reason for using %_Call(...) inste
Dan Ehrenberg
2016/02/10 09:25:54
Nope. (I was somehow thinking that it would be red
|
| if (mapping) { |
| mappedValue = %_Call(mapfn, receiver, nextValue, k); |
| } else { |
| @@ -1801,6 +1788,8 @@ function ArrayFrom(arrayLike, mapfn, receiver) { |
| AddArrayElement(this, result, k, mappedValue); |
| k++; |
| } |
| + result.length = k; |
| + return result; |
| } else { |
| var len = TO_LENGTH(items.length); |
| result = %IsConstructor(this) ? new this(len) : new GlobalArray(len); |