Index: src/array.js |
diff --git a/src/array.js b/src/array.js |
index 74868e746ba07cd61d0c33cd2061f2111c6e21b5..214065c7bf3b087c5d8f61f54cc3f955efff619d 100644 |
--- a/src/array.js |
+++ b/src/array.js |
@@ -1017,16 +1017,18 @@ function ArrayFilter(f, receiver) { |
receiver = ToObject(receiver); |
} |
- var result = []; |
- var result_length = 0; |
+ var result = new $Array(); |
+ 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)) { |
- result[result_length++] = current; |
+ accumulator[accumulator_length++] = current; |
} |
} |
} |
+ %MoveArrayContents(accumulator, result); |
return result; |
} |