Skip to content

Commit a93ffde

Browse files
camillobruniCommit bot
authored andcommitted
[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}
1 parent 819b40a commit a93ffde

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

src/array.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -915,15 +915,19 @@ function InnerArraySort(array, length, comparefn) {
915915
};
916916

917917
var GetThirdIndex = function(a, from, to) {
918-
var t_array = [];
918+
var t_array = new InternalArray();
919919
// Use both 'from' and 'to' to determine the pivot candidates.
920920
var increment = 200 + ((to - from) & 15);
921-
for (var i = from + 1, j = 0; i < to - 1; i += increment, j++) {
921+
var j = 0;
922+
from += 1;
923+
to -= 1;
924+
for (var i = from; i < to; i += increment) {
922925
t_array[j] = [i, a[i]];
926+
j++;
923927
}
924-
%_CallFunction(t_array, function(a, b) {
928+
t_array.sort(function(a, b) {
925929
return comparefn(a[1], b[1]);
926-
}, ArraySort);
930+
});
927931
var third_index = t_array[t_array.length >> 1][0];
928932
return third_index;
929933
}

0 commit comments

Comments
 (0)