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

Unified Diff: src/array.js

Issue 1525040: Do not preconvert to string as it apparently has minimal performance benefit. (Closed)
Patch Set: Created 10 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/array.js
diff --git a/src/array.js b/src/array.js
index 54d7e57b833b9e214892efd9d6f8006a41fb73fc..a718fdcc44e8fda523f15453b0b228648b9c69f1 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;
« 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