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

Unified Diff: dart/frog/leg/lib/dual_pivot_quicksort.dart

Issue 9536020: Work around buggy break in List.sort and optimize constant folding of negative values. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 10 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 | dart/frog/leg/ssa/builder.dart » ('j') | dart/frog/leg/ssa/builder.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/frog/leg/lib/dual_pivot_quicksort.dart
diff --git a/dart/frog/leg/lib/dual_pivot_quicksort.dart b/dart/frog/leg/lib/dual_pivot_quicksort.dart
index d2cee58d261d43c7378ecc1b066c1a98354d9b63..9f2f8019f157c2261aa8823b93047582a6e99bd7 100644
--- a/dart/frog/leg/lib/dual_pivot_quicksort.dart
+++ b/dart/frog/leg/lib/dual_pivot_quicksort.dart
@@ -154,7 +154,8 @@ class DualPivotQuicksort {
// Note that in the latter case invariant 2 will be violated for a
// short amount of time. The invariant will be restored when the
// pivots are put into their final positions.
- while (true) {
+ bool done = false;
+ while (!done) {
comp = compare(a[great], pivot);
if (comp > 0) {
great--;
@@ -166,14 +167,14 @@ class DualPivotQuicksort {
a[k] = a[less];
a[less++] = a[great];
a[great--] = ak;
- break;
+ done = true;
} else {
// comp == 0;
a[k] = a[great];
a[great--] = ak;
// Note: if great < k then we will exit the outer loop and fix
// invariant 2 (which we just violated).
- break;
+ done = true;
}
}
}
@@ -208,11 +209,12 @@ class DualPivotQuicksort {
} else {
int comp_pivot2 = compare(ak, pivot2);
if (comp_pivot2 > 0) {
- while (true) {
+ bool done = false;
+ while (!done) {
int comp = compare(a[great], pivot2);
if (comp > 0) {
great--;
- if (great < k) break;
+ if (great < k) done = true;
// This is the only location inside the loop where a new
// iteration is started.
// continue;
@@ -229,7 +231,7 @@ class DualPivotQuicksort {
a[k] = a[great];
a[great--] = ak;
}
- break;
+ done = true;
}
}
}
@@ -298,11 +300,12 @@ class DualPivotQuicksort {
} else {
int comp_pivot2 = compare(ak, pivot2);
if (comp_pivot2 == 0) {
- while (true) {
+ bool done = false;
+ while (!done) {
int comp = compare(a[great], pivot2);
if (comp == 0) {
great--;
- if (great < k) break;
+ if (great < k) done = true;
// This is the only location inside the loop where a new
// iteration is started.
// continue;
@@ -319,7 +322,7 @@ class DualPivotQuicksort {
a[k] = a[great];
a[great--] = ak;
}
- break;
+ done = true;
}
}
}
« no previous file with comments | « no previous file | dart/frog/leg/ssa/builder.dart » ('j') | dart/frog/leg/ssa/builder.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698