[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}
This commit is contained in:
parent
819b40aae8
commit
a93ffde366
12
src/array.js
12
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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user