Index: src/array.js |
diff --git a/src/array.js b/src/array.js |
index 26f050d71065f8489a20815b1db74edb2f99e32f..0c4985ed86aed8e22a9ee3b7fa055da761778743 100644 |
--- a/src/array.js |
+++ b/src/array.js |
@@ -915,15 +915,19 @@ function InnerArraySort(array, length, comparefn) { |
}; |
var GetThirdIndex = function(a, from, to) { |
- var t_array = []; |
+ var t_array = new InternalArray(); |
// Use both 'from' and 'to' to determine the pivot candidates. |
var increment = 200 + ((to - from) & 15); |
- for (var i = from + 1, j = 0; i < to - 1; i += increment, j++) { |
+ var j = 0; |
+ from += 1; |
+ to -= 1; |
+ for (var i = from; i < to; i += increment) { |
t_array[j] = [i, a[i]]; |
+ j++; |
} |
- %_CallFunction(t_array, function(a, b) { |
+ t_array.sort(function(a, b) { |
return comparefn(a[1], b[1]); |
- }, ArraySort); |
+ }); |
var third_index = t_array[t_array.length >> 1][0]; |
return third_index; |
} |