OLD | NEW |
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 "use strict"; | 5 "use strict"; |
6 | 6 |
7 // This file relies on the fact that the following declarations have been made | 7 // This file relies on the fact that the following declarations have been made |
8 // in runtime.js: | 8 // in runtime.js: |
9 // var $Array = global.Array; | 9 // var $Array = global.Array; |
10 | 10 |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 } | 227 } |
228 } | 228 } |
229 } | 229 } |
230 } | 230 } |
231 } | 231 } |
232 | 232 |
233 | 233 |
234 // This function implements the optimized splice implementation that can use | 234 // This function implements the optimized splice implementation that can use |
235 // special array operations to handle sparse arrays in a sensible fashion. | 235 // special array operations to handle sparse arrays in a sensible fashion. |
236 function SmartMove(array, start_i, del_count, len, num_additional_args) { | 236 function SmartMove(array, start_i, del_count, len, num_additional_args) { |
| 237 // Bail out if no moving is necessary. |
| 238 if (num_additional_args === del_count) return; |
237 // Move data to new array. | 239 // Move data to new array. |
238 var new_array = new InternalArray(len - del_count + num_additional_args); | 240 var new_array = new InternalArray(len - del_count + num_additional_args); |
239 var indices = %GetArrayKeys(array, len); | 241 var indices = %GetArrayKeys(array, len); |
240 if (IS_NUMBER(indices)) { | 242 if (IS_NUMBER(indices)) { |
241 var limit = indices; | 243 var limit = indices; |
242 for (var i = 0; i < start_i && i < limit; ++i) { | 244 for (var i = 0; i < start_i && i < limit; ++i) { |
243 var current = array[i]; | 245 var current = array[i]; |
244 if (!IS_UNDEFINED(current) || i in array) { | 246 if (!IS_UNDEFINED(current) || i in array) { |
245 new_array[i] = current; | 247 new_array[i] = current; |
246 } | 248 } |
(...skipping 1319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1566 )); | 1568 )); |
1567 | 1569 |
1568 SetUpLockedPrototype(InternalPackedArray, $Array(), $Array( | 1570 SetUpLockedPrototype(InternalPackedArray, $Array(), $Array( |
1569 "join", getFunction("join", ArrayJoin), | 1571 "join", getFunction("join", ArrayJoin), |
1570 "pop", getFunction("pop", ArrayPop), | 1572 "pop", getFunction("pop", ArrayPop), |
1571 "push", getFunction("push", ArrayPush) | 1573 "push", getFunction("push", ArrayPush) |
1572 )); | 1574 )); |
1573 } | 1575 } |
1574 | 1576 |
1575 SetUpArray(); | 1577 SetUpArray(); |
OLD | NEW |