Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: src/array.js

Issue 1316673008: [builtins] Removing %_CallFunction in GetThirdIndex. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@2015-09-09_CallFunction_cleanup_1325573004
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 (function(global, utils) { 5 (function(global, utils) {
6 6
7 "use strict"; 7 "use strict";
8 8
9 %CheckIsBootstrapping(); 9 %CheckIsBootstrapping();
10 10
(...skipping 897 matching lines...) Expand 10 before | Expand all | Expand 10 after
908 a[j + 1] = tmp; 908 a[j + 1] = tmp;
909 } else { 909 } else {
910 break; 910 break;
911 } 911 }
912 } 912 }
913 a[j + 1] = element; 913 a[j + 1] = element;
914 } 914 }
915 }; 915 };
916 916
917 var GetThirdIndex = function(a, from, to) { 917 var GetThirdIndex = function(a, from, to) {
918 var t_array = []; 918 var t_array = new InternalArray();
919 // Use both 'from' and 'to' to determine the pivot candidates. 919 // Use both 'from' and 'to' to determine the pivot candidates.
920 var increment = 200 + ((to - from) & 15); 920 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) {
922 t_array[j] = [i, a[i]]; 925 t_array[j] = [i, a[i]];
926 j++;
923 } 927 }
924 %_CallFunction(t_array, function(a, b) { 928 t_array.sort(function(a, b) {
925 return comparefn(a[1], b[1]); 929 return comparefn(a[1], b[1]);
926 }, ArraySort); 930 });
927 var third_index = t_array[t_array.length >> 1][0]; 931 var third_index = t_array[t_array.length >> 1][0];
928 return third_index; 932 return third_index;
929 } 933 }
930 934
931 var QuickSort = function QuickSort(a, from, to) { 935 var QuickSort = function QuickSort(a, from, to) {
932 var third_index = 0; 936 var third_index = 0;
933 while (true) { 937 while (true) {
934 // Insertion sort is faster for short arrays. 938 // Insertion sort is faster for short arrays.
935 if (to - from <= 10) { 939 if (to - from <= 10) {
936 InsertionSort(a, from, to); 940 InsertionSort(a, from, to);
(...skipping 717 matching lines...) Expand 10 before | Expand all | Expand 10 after
1654 %InstallToContext([ 1658 %InstallToContext([
1655 "array_pop", ArrayPop, 1659 "array_pop", ArrayPop,
1656 "array_push", ArrayPush, 1660 "array_push", ArrayPush,
1657 "array_shift", ArrayShift, 1661 "array_shift", ArrayShift,
1658 "array_splice", ArraySplice, 1662 "array_splice", ArraySplice,
1659 "array_slice", ArraySlice, 1663 "array_slice", ArraySlice,
1660 "array_unshift", ArrayUnshift, 1664 "array_unshift", ArrayUnshift,
1661 ]); 1665 ]);
1662 1666
1663 }); 1667 });
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698