Index: src/js/array.js |
diff --git a/src/js/array.js b/src/js/array.js |
index be36145feb5ad7e95043836bc057f1ed384941a4..4146600ed030e97de606e0a7ea29bbf2a3374192 100644 |
--- a/src/js/array.js |
+++ b/src/js/array.js |
@@ -1196,7 +1196,9 @@ function InnerArrayFilter(f, receiver, array, length) { |
} |
} |
} |
- return accumulator; |
+ var result = new GlobalArray(); |
+ %MoveArrayContents(accumulator, result); |
+ return result; |
} |
function ArrayFilter(f, receiver) { |
@@ -1206,10 +1208,7 @@ function ArrayFilter(f, receiver) { |
// loop will not affect the looping and side effects are visible. |
var array = TO_OBJECT(this); |
var length = TO_LENGTH_OR_UINT32(array.length); |
- var accumulator = InnerArrayFilter(f, receiver, array, length); |
- var result = new GlobalArray(); |
- %MoveArrayContents(accumulator, result); |
- return result; |
+ return InnerArrayFilter(f, receiver, array, length); |
} |
function InnerArrayForEach(f, receiver, array, length) { |
@@ -1309,7 +1308,9 @@ function InnerArrayMap(f, receiver, array, length) { |
accumulator[i] = %_Call(f, receiver, element, i, array); |
} |
} |
- return accumulator; |
+ var result = new GlobalArray(); |
+ %MoveArrayContents(accumulator, result); |
+ return result; |
} |
@@ -1320,10 +1321,7 @@ function ArrayMap(f, receiver) { |
// loop will not affect the looping and side effects are visible. |
var array = TO_OBJECT(this); |
var length = TO_LENGTH_OR_UINT32(array.length); |
- var accumulator = InnerArrayMap(f, receiver, array, length); |
- var result = new GlobalArray(); |
- %MoveArrayContents(accumulator, result); |
- return result; |
+ return InnerArrayMap(f, receiver, array, length); |
} |