Chromium Code Reviews| Index: src/js/array.js |
| diff --git a/src/js/array.js b/src/js/array.js |
| index bbc84b164a404ade90ca3dafeeb64186e3c1fd0b..62fcfac9c8caa73b9038ce536cb9c39a1ac9f593 100644 |
| --- a/src/js/array.js |
| +++ b/src/js/array.js |
| @@ -1001,57 +1001,6 @@ function ArraySort(comparefn) { |
| return InnerArraySort(array, length, comparefn); |
| } |
| - |
| -// The following functions cannot be made efficient on sparse arrays while |
| -// preserving the semantics, since the calls to the receiver function can add |
| -// or delete elements from the array. |
| -function InnerArrayFilter(f, receiver, array, length, result) { |
| - var result_length = 0; |
| - for (var i = 0; i < length; i++) { |
| - if (i in array) { |
| - var element = array[i]; |
| - if (%_Call(f, receiver, element, i, array)) { |
| - %CreateDataProperty(result, result_length, element); |
| - result_length++; |
| - } |
| - } |
| - } |
| - return result; |
| -} |
| - |
| - |
| - |
| -function ArrayFilter(f, receiver) { |
| - CHECK_OBJECT_COERCIBLE(this, "Array.prototype.filter"); |
| - |
| - // Pull out the length so that modifications to the length in the |
| - // loop will not affect the looping and side effects are visible. |
| - var array = TO_OBJECT(this); |
| - var length = TO_LENGTH(array.length); |
| - if (!IS_CALLABLE(f)) throw %make_type_error(kCalledNonCallable, f); |
| - var result = ArraySpeciesCreate(array, 0); |
| - return InnerArrayFilter(f, receiver, array, length, result); |
| -} |
| - |
| -function ArrayMap(f, receiver) { |
| - CHECK_OBJECT_COERCIBLE(this, "Array.prototype.map"); |
| - |
| - // Pull out the length so that modifications to the length in the |
| - // loop will not affect the looping and side effects are visible. |
| - var array = TO_OBJECT(this); |
| - var length = TO_LENGTH(array.length); |
| - if (!IS_CALLABLE(f)) throw %make_type_error(kCalledNonCallable, f); |
| - var result = ArraySpeciesCreate(array, length); |
| - for (var i = 0; i < length; i++) { |
| - if (i in array) { |
| - var element = array[i]; |
| - %CreateDataProperty(result, i, %_Call(f, receiver, element, i, array)); |
| - } |
| - } |
| - return result; |
| -} |
| - |
| - |
|
danno
2017/04/03 15:35:27
Nice. I like it.
|
| function ArrayLastIndexOf(element, index) { |
| CHECK_OBJECT_COERCIBLE(this, "Array.prototype.lastIndexOf"); |
| @@ -1382,8 +1331,6 @@ utils.InstallFunctions(GlobalArray.prototype, DONT_ENUM, [ |
| "slice", getFunction("slice", ArraySlice, 2), |
| "splice", getFunction("splice", ArraySplice, 2), |
| "sort", getFunction("sort", ArraySort), |
| - "filter", getFunction("filter", ArrayFilter, 1), |
| - "map", getFunction("map", ArrayMap, 1), |
| "indexOf", getFunction("indexOf", null, 1), |
| "lastIndexOf", getFunction("lastIndexOf", ArrayLastIndexOf, 1), |
| "copyWithin", getFunction("copyWithin", ArrayCopyWithin, 2), |
| @@ -1440,7 +1387,6 @@ utils.Export(function(to) { |
| to.ArrayPush = ArrayPush; |
| to.ArrayToString = ArrayToString; |
| to.ArrayValues = IteratorFunctions.values, |
| - to.InnerArrayFilter = InnerArrayFilter; |
| to.InnerArrayFind = InnerArrayFind; |
| to.InnerArrayFindIndex = InnerArrayFindIndex; |
| to.InnerArrayJoin = InnerArrayJoin; |