Index: src/array.js |
diff --git a/src/array.js b/src/array.js |
index 104fe3f6418746914ec8cc200263036e800ce4f4..ab8bb39a848ea34a17dc5a47bc04920e3866007a 100644 |
--- a/src/array.js |
+++ b/src/array.js |
@@ -1147,28 +1147,16 @@ function ArrayFilter(f, receiver) { |
var result = new $Array(); |
var accumulator = new InternalArray(); |
var accumulator_length = 0; |
- if (%DebugCallbackSupportsStepping(f)) { |
- for (var i = 0; i < length; i++) { |
- if (i in array) { |
- var element = array[i]; |
- // Prepare break slots for debugger step in. |
- %DebugPrepareStepInIfStepping(f); |
- if (%_CallFunction(receiver, element, i, array, f)) { |
- accumulator[accumulator_length++] = element; |
- } |
- } |
- } |
- } else { |
- // This is a duplicate of the previous loop sans debug stepping. |
- for (var i = 0; i < length; i++) { |
- if (i in array) { |
- var element = array[i]; |
- if (%_CallFunction(receiver, element, i, array, f)) { |
- accumulator[accumulator_length++] = element; |
- } |
+ var stepping = %_DebugCallbackSupportsStepping(f); |
+ for (var i = 0; i < length; i++) { |
+ if (i in array) { |
+ var element = array[i]; |
+ // Prepare break slots for debugger step in. |
+ if (stepping) %DebugPrepareStepInIfStepping(f); |
+ if (%_CallFunction(receiver, element, i, array, f)) { |
+ accumulator[accumulator_length++] = element; |
} |
} |
- // End of duplicate. |
} |
%MoveArrayContents(accumulator, result); |
return result; |
@@ -1192,24 +1180,14 @@ function ArrayForEach(f, receiver) { |
receiver = ToObject(receiver); |
} |
- if (%DebugCallbackSupportsStepping(f)) { |
- for (var i = 0; i < length; i++) { |
- if (i in array) { |
- var element = array[i]; |
- // Prepare break slots for debugger step in. |
- %DebugPrepareStepInIfStepping(f); |
- %_CallFunction(receiver, element, i, array, f); |
- } |
- } |
- } else { |
- // This is a duplicate of the previous loop sans debug stepping. |
- for (var i = 0; i < length; i++) { |
- if (i in array) { |
- var element = array[i]; |
- %_CallFunction(receiver, element, i, array, f); |
- } |
+ var stepping = %_DebugCallbackSupportsStepping(f); |
+ for (var i = 0; i < length; i++) { |
+ if (i in array) { |
+ var element = array[i]; |
+ // Prepare break slots for debugger step in. |
+ if (stepping) %DebugPrepareStepInIfStepping(f); |
+ %_CallFunction(receiver, element, i, array, f); |
} |
- // End of duplicate. |
} |
} |
@@ -1233,24 +1211,14 @@ function ArraySome(f, receiver) { |
receiver = ToObject(receiver); |
} |
- if (%DebugCallbackSupportsStepping(f)) { |
- for (var i = 0; i < length; i++) { |
- if (i in array) { |
- var element = array[i]; |
- // Prepare break slots for debugger step in. |
- %DebugPrepareStepInIfStepping(f); |
- if (%_CallFunction(receiver, element, i, array, f)) return true; |
- } |
+ var stepping = %_DebugCallbackSupportsStepping(f); |
+ for (var i = 0; i < length; i++) { |
+ if (i in array) { |
+ var element = array[i]; |
+ // Prepare break slots for debugger step in. |
+ if (stepping) %DebugPrepareStepInIfStepping(f); |
+ if (%_CallFunction(receiver, element, i, array, f)) return true; |
} |
- } else { |
- // This is a duplicate of the previous loop sans debug stepping. |
- for (var i = 0; i < length; i++) { |
- if (i in array) { |
- var element = array[i]; |
- if (%_CallFunction(receiver, element, i, array, f)) return true; |
- } |
- } |
- // End of duplicate. |
} |
return false; |
} |
@@ -1273,24 +1241,14 @@ function ArrayEvery(f, receiver) { |
receiver = ToObject(receiver); |
} |
- if (%DebugCallbackSupportsStepping(f)) { |
- for (var i = 0; i < length; i++) { |
- if (i in array) { |
- var element = array[i]; |
- // Prepare break slots for debugger step in. |
- %DebugPrepareStepInIfStepping(f); |
- if (!%_CallFunction(receiver, element, i, array, f)) return false; |
- } |
+ var stepping = %_DebugCallbackSupportsStepping(f); |
+ for (var i = 0; i < length; i++) { |
+ if (i in array) { |
+ var element = array[i]; |
+ // Prepare break slots for debugger step in. |
+ if (stepping) %DebugPrepareStepInIfStepping(f); |
+ if (!%_CallFunction(receiver, element, i, array, f)) return false; |
} |
- } else { |
- // This is a duplicate of the previous loop sans debug stepping. |
- for (var i = 0; i < length; i++) { |
- if (i in array) { |
- var element = array[i]; |
- if (!%_CallFunction(receiver, element, i, array, f)) return false; |
- } |
- } |
- // End of duplicate. |
} |
return true; |
} |
@@ -1314,24 +1272,14 @@ function ArrayMap(f, receiver) { |
var result = new $Array(); |
var accumulator = new InternalArray(length); |
- if (%DebugCallbackSupportsStepping(f)) { |
- for (var i = 0; i < length; i++) { |
- if (i in array) { |
- var element = array[i]; |
- // Prepare break slots for debugger step in. |
- %DebugPrepareStepInIfStepping(f); |
- accumulator[i] = %_CallFunction(receiver, element, i, array, f); |
- } |
+ var stepping = %_DebugCallbackSupportsStepping(f); |
+ for (var i = 0; i < length; i++) { |
+ if (i in array) { |
+ var element = array[i]; |
+ // Prepare break slots for debugger step in. |
+ if (stepping) %DebugPrepareStepInIfStepping(f); |
+ accumulator[i] = %_CallFunction(receiver, element, i, array, f); |
} |
- } else { |
- // This is a duplicate of the previous loop sans debug stepping. |
- for (var i = 0; i < length; i++) { |
- if (i in array) { |
- var element = array[i]; |
- accumulator[i] = %_CallFunction(receiver, element, i, array, f); |
- } |
- } |
- // End of duplicate. |
} |
%MoveArrayContents(accumulator, result); |
return result; |
@@ -1471,27 +1419,14 @@ function ArrayReduce(callback, current) { |
} |
var receiver = %GetDefaultReceiver(callback); |
- |
- if (%DebugCallbackSupportsStepping(callback)) { |
- for (; i < length; i++) { |
- if (i in array) { |
- var element = array[i]; |
- // Prepare break slots for debugger step in. |
- %DebugPrepareStepInIfStepping(callback); |
- current = |
- %_CallFunction(receiver, current, element, i, array, callback); |
- } |
+ var stepping = %_DebugCallbackSupportsStepping(callback); |
+ for (; i < length; i++) { |
+ if (i in array) { |
+ var element = array[i]; |
+ // Prepare break slots for debugger step in. |
+ if (stepping) %DebugPrepareStepInIfStepping(callback); |
+ current = %_CallFunction(receiver, current, element, i, array, callback); |
} |
- } else { |
- // This is a duplicate of the previous loop sans debug stepping. |
- for (; i < length; i++) { |
- if (i in array) { |
- var element = array[i]; |
- current = |
- %_CallFunction(receiver, current, element, i, array, callback); |
- } |
- } |
- // End of duplicate. |
} |
return current; |
} |
@@ -1521,27 +1456,14 @@ function ArrayReduceRight(callback, current) { |
} |
var receiver = %GetDefaultReceiver(callback); |
- |
- if (%DebugCallbackSupportsStepping(callback)) { |
- for (; i >= 0; i--) { |
- if (i in array) { |
- var element = array[i]; |
- // Prepare break slots for debugger step in. |
- %DebugPrepareStepInIfStepping(callback); |
- current = |
- %_CallFunction(receiver, current, element, i, array, callback); |
- } |
- } |
- } else { |
- // This is a duplicate of the previous loop sans debug stepping. |
- for (; i >= 0; i--) { |
- if (i in array) { |
- var element = array[i]; |
- current = |
- %_CallFunction(receiver, current, element, i, array, callback); |
- } |
+ var stepping = %_DebugCallbackSupportsStepping(callback); |
+ for (; i >= 0; i--) { |
+ if (i in array) { |
+ var element = array[i]; |
+ // Prepare break slots for debugger step in. |
+ if (stepping) %DebugPrepareStepInIfStepping(callback); |
+ current = %_CallFunction(receiver, current, element, i, array, callback); |
} |
- // End of duplicate. |
} |
return current; |
} |