diff options
| author | Ben Murdoch <benm@google.com> | 2012-04-11 10:23:59 +0100 |
|---|---|---|
| committer | Ben Murdoch <benm@google.com> | 2012-04-11 15:40:41 +0100 |
| commit | 5d4cdbf7a67d3662fa0bee4efdb7edd8daec9b0b (patch) | |
| tree | 7b717e53b80c4a64bf9b723aabcf7c909ae3c243 /src/array.js | |
| parent | c7cc028aaeedbbfa11c11d0b7b243b3d9e837ed9 (diff) | |
| download | android_external_v8-5d4cdbf7a67d3662fa0bee4efdb7edd8daec9b0b.tar.gz android_external_v8-5d4cdbf7a67d3662fa0bee4efdb7edd8daec9b0b.tar.bz2 android_external_v8-5d4cdbf7a67d3662fa0bee4efdb7edd8daec9b0b.zip | |
Merge V8 3.9 at 3.9.24.9
http://v8.googlecode.com/svn/branches/3.9@11260
Bug: 5688872
Change-Id: Iddd944e82189d92df3fc427dc5f0d3f1b2f0c6c8
Diffstat (limited to 'src/array.js')
| -rw-r--r-- | src/array.js | 66 |
1 files changed, 33 insertions, 33 deletions
diff --git a/src/array.js b/src/array.js index 16e37c5a..daa75d57 100644 --- a/src/array.js +++ b/src/array.js @@ -27,7 +27,7 @@ // This file relies on the fact that the following declarations have been made // in runtime.js: -// const $Array = global.Array; +// var $Array = global.Array; // ------------------------------------------------------------------- @@ -757,7 +757,7 @@ function ArraySort(comparefn) { } var receiver = %GetDefaultReceiver(comparefn); - function InsertionSort(a, from, to) { + var InsertionSort = function InsertionSort(a, from, to) { for (var i = from + 1; i < to; i++) { var element = a[i]; for (var j = i - 1; j >= from; j--) { @@ -771,9 +771,9 @@ function ArraySort(comparefn) { } a[j + 1] = element; } - } + }; - function QuickSort(a, from, to) { + var QuickSort = function QuickSort(a, from, to) { // Insertion sort is faster for short arrays. if (to - from <= 10) { InsertionSort(a, from, to); @@ -841,12 +841,12 @@ function ArraySort(comparefn) { } QuickSort(a, from, low_end); QuickSort(a, high_start, to); - } + }; // Copy elements in the range 0..length from obj's prototype chain // to obj itself, if obj has holes. Return one more than the maximal index // of a prototype property. - function CopyFromPrototype(obj, length) { + var CopyFromPrototype = function CopyFromPrototype(obj, length) { var max = 0; for (var proto = obj.__proto__; proto; proto = proto.__proto__) { var indices = %GetArrayKeys(proto, length); @@ -873,12 +873,12 @@ function ArraySort(comparefn) { } } return max; - } + }; // Set a value of "undefined" on all indices in the range from..to // where a prototype of obj has an element. I.e., shadow all prototype // elements in that range. - function ShadowPrototypeElements(obj, from, to) { + var ShadowPrototypeElements = function(obj, from, to) { for (var proto = obj.__proto__; proto; proto = proto.__proto__) { var indices = %GetArrayKeys(proto, to); if (indices.length > 0) { @@ -901,9 +901,9 @@ function ArraySort(comparefn) { } } } - } + }; - function SafeRemoveArrayHoles(obj) { + var SafeRemoveArrayHoles = function SafeRemoveArrayHoles(obj) { // Copy defined elements from the end to fill in all holes and undefineds // in the beginning of the array. Write undefineds and holes at the end // after loop is finished. @@ -958,7 +958,7 @@ function ArraySort(comparefn) { // Return the number of defined elements. return first_undefined; - } + }; var length = TO_UINT32(this.length); if (length < 2) return this; @@ -1024,10 +1024,10 @@ function ArrayFilter(f, receiver) { var accumulator = new InternalArray(); var accumulator_length = 0; for (var i = 0; i < length; i++) { - var current = array[i]; - if (!IS_UNDEFINED(current) || i in array) { - if (%_CallFunction(receiver, current, i, array, f)) { - accumulator[accumulator_length++] = current; + if (i in array) { + var element = array[i]; + if (%_CallFunction(receiver, element, i, array, f)) { + accumulator[accumulator_length++] = element; } } } @@ -1057,9 +1057,9 @@ function ArrayForEach(f, receiver) { } for (var i = 0; i < length; i++) { - var current = array[i]; - if (!IS_UNDEFINED(current) || i in array) { - %_CallFunction(receiver, current, i, array, f); + if (i in array) { + var element = array[i]; + %_CallFunction(receiver, element, i, array, f); } } } @@ -1088,9 +1088,9 @@ function ArraySome(f, receiver) { } for (var i = 0; i < length; i++) { - var current = array[i]; - if (!IS_UNDEFINED(current) || i in array) { - if (%_CallFunction(receiver, current, i, array, f)) return true; + if (i in array) { + var element = array[i]; + if (%_CallFunction(receiver, element, i, array, f)) return true; } } return false; @@ -1118,9 +1118,9 @@ function ArrayEvery(f, receiver) { } for (var i = 0; i < length; i++) { - var current = array[i]; - if (!IS_UNDEFINED(current) || i in array) { - if (!%_CallFunction(receiver, current, i, array, f)) return false; + if (i in array) { + var element = array[i]; + if (!%_CallFunction(receiver, element, i, array, f)) return false; } } return true; @@ -1149,9 +1149,9 @@ function ArrayMap(f, receiver) { var result = new $Array(); var accumulator = new InternalArray(length); for (var i = 0; i < length; i++) { - var current = array[i]; - if (!IS_UNDEFINED(current) || i in array) { - accumulator[i] = %_CallFunction(receiver, current, i, array, f); + if (i in array) { + var element = array[i]; + accumulator[i] = %_CallFunction(receiver, element, i, array, f); } } %MoveArrayContents(accumulator, result); @@ -1308,8 +1308,8 @@ function ArrayReduce(callback, current) { var receiver = %GetDefaultReceiver(callback); for (; i < length; i++) { - var element = array[i]; - if (!IS_UNDEFINED(element) || i in array) { + if (i in array) { + var element = array[i]; current = %_CallFunction(receiver, current, element, i, array, callback); } } @@ -1345,8 +1345,8 @@ function ArrayReduceRight(callback, current) { var receiver = %GetDefaultReceiver(callback); for (; i >= 0; i--) { - var element = array[i]; - if (!IS_UNDEFINED(element) || i in array) { + if (i in array) { + var element = array[i]; current = %_CallFunction(receiver, current, element, i, array, callback); } } @@ -1373,7 +1373,7 @@ function SetUpArray() { var specialFunctions = %SpecialArrayFunctions({}); - function getFunction(name, jsBuiltin, len) { + var getFunction = function(name, jsBuiltin, len) { var f = jsBuiltin; if (specialFunctions.hasOwnProperty(name)) { f = specialFunctions[name]; @@ -1382,7 +1382,7 @@ function SetUpArray() { %FunctionSetLength(f, len); } return f; - } + }; // Set up non-enumerable functions of the Array.prototype object and // set their names. |
