From cdbbd7fa49e2ad1e6313f2fcd2a57b16aa111d96 Mon Sep 17 00:00:00 2001 From: "antonm@chromium.org" Date: Tue, 20 Apr 2010 11:29:32 +0000 Subject: [PATCH] Do not preconvert to string as it apparently has minimal performance benefit. Review URL: http://codereview.chromium.org/1525040 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4448 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/array.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/array.js b/src/array.js index 54d7e57b83..a718fdcc44 100644 --- a/src/array.js +++ b/src/array.js @@ -712,10 +712,9 @@ function ArraySort(comparefn) { function InsertionSort(a, from, to) { for (var i = from + 1; i < to; i++) { var element = a[i]; - var key = %_IsSmi(element) ? element : ToString(element); for (var j = i - 1; j >= from; j--) { var tmp = a[j]; - var order = Compare(tmp, key); + var order = Compare(tmp, element); if (order > 0) { a[j + 1] = tmp; } else { @@ -734,9 +733,6 @@ function ArraySort(comparefn) { } var pivot_index = $floor($random() * (to - from)) + from; var pivot = a[pivot_index]; - // Pre-convert the element to a string for comparison if we know - // it will happen on each compare anyway. - var pivot_key = %_IsSmi(pivot) ? pivot : ToString(pivot); // Issue 95: Keep the pivot element out of the comparisons to avoid // infinite recursion if comparefn(pivot, pivot) != 0. a[pivot_index] = a[from]; @@ -747,7 +743,7 @@ function ArraySort(comparefn) { // From i to high_start are elements that haven't been compared yet. for (var i = from + 1; i < high_start; ) { var element = a[i]; - var order = Compare(element, pivot_key); + var order = Compare(element, pivot); if (order < 0) { a[i] = a[low_end]; a[low_end] = element;