Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 'use strict'; | |
| 6 | |
| 7 // ------------------------------------------------------------------- | |
| 8 | |
| 9 function SpreadArguments(a) { | |
| 10 // Each argument should be an array | |
| 11 var count = %_ArgumentsLength(); | |
| 12 var array = (new InternalArray()).concat(%_Arguments(0)); | |
|
arv (Not doing code reviews)
2015/02/23 17:55:56
Why not Push. concat creates a new array so we cre
rossberg
2015/02/24 16:22:47
+1, use push
| |
| 13 | |
| 14 for (var i = 1; i < count; ++i) { | |
| 15 array = array.concat(%_Arguments(i)); | |
|
arv (Not doing code reviews)
2015/02/23 17:55:56
push here as well
or roll your own loop. It is us
| |
| 16 } | |
| 17 | |
| 18 return array; | |
| 19 } | |
| 20 | |
| 21 function SpreadIterable(collection) { | |
| 22 if (IS_NULL_OR_UNDEFINED(collection)) { | |
| 23 throw MakeTypeError("not_iterable", [collection]); | |
| 24 } | |
| 25 | |
| 26 var iterable = collection[symbolIterator]; | |
| 27 var iterator = GetIterator(collection, iterable); | |
|
arv (Not doing code reviews)
2015/02/23 17:55:56
I'm on a mission to replace all of these with for-
| |
| 28 var args = new InternalArray(); | |
| 29 | |
| 30 while (true) { | |
| 31 var next = iterator.next(); | |
| 32 | |
| 33 if (!IS_OBJECT(next)) { | |
| 34 throw MakeTypeError("iterator_result_not_an_object", [next]); | |
| 35 } | |
| 36 | |
| 37 if (next.done) { | |
| 38 break; | |
| 39 } | |
| 40 | |
| 41 args.push(next.value); | |
| 42 } | |
| 43 | |
| 44 return args; | |
| 45 } | |
| OLD | NEW |