Commit a93ffde3 authored by cbruni's avatar cbruni Committed by Commit bot

[builtins] Removing %_CallFunction in GetThirdIndex.

By using an InternArray for the pivot calculation we can get rid of yet
another %_CallFunction.

Review URL: https://codereview.chromium.org/1316673008

Cr-Commit-Position: refs/heads/master@{#30636}
parent 819b40aa
......@@ -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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment