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

Unified Diff: src/array.js

Issue 5003: Adding comment to the fix of issue 95. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 12 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 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
===================================================================
--- src/array.js (revision 382)
+++ src/array.js (working copy)
@@ -672,6 +672,8 @@
if (from >= to - 1) return;
var pivot_index = $floor($random() * (to - from)) + from;
var pivot = a[pivot_index];
+ // Issue 95: Keep the pivot element out of the comparisons to avoid
+ // infinite recursion if comparefn(pivot, pivot) != 0.
a[pivot_index] = a[to - 1];
a[to - 1] = pivot;
var low_end = from; // Upper bound of the elements lower than pivot.
@@ -692,6 +694,7 @@
i++;
}
}
+ // Restore the pivot element to its rightful place.
a[to - 1] = a[high_start];
a[high_start] = pivot;
high_start++;
« 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