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

Unified Diff: sdk/lib/internal/sort.dart

Issue 2008373002: Make sort method generic. This eliminates a large number of dynamic calls that slow down sorting un… (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 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: sdk/lib/internal/sort.dart
diff --git a/sdk/lib/internal/sort.dart b/sdk/lib/internal/sort.dart
index 562d8b834bd030752ecd10e4a66831401fb2b7a2..63037ea4d6388bad057aec257d0db30247540ddc 100644
--- a/sdk/lib/internal/sort.dart
+++ b/sdk/lib/internal/sort.dart
@@ -29,7 +29,7 @@ class Sort {
* The function's behavior must be consistent. It must not return different
* results for the same values.
*/
- static void sort(List a, int compare(a, b)) {
+ static void sort/*<E>*/(List/*<E>*/ a, int compare(dynamic /*=E*/ a, dynamic /*=E*/ b)) {
_doSort(a, 0, a.length - 1, compare);
}
@@ -42,7 +42,7 @@ class Sort {
*
* See [:sort:] for requirements of the [:compare:] function.
*/
- static void sortRange(List a, int from, int to, int compare(a, b)) {
+ static void sortRange/*<E>*/(List/*<E>*/ a, int from, int to, int compare(dynamic /*=E*/ a, dynamic /*=E*/ b)) {
if ((from < 0) || (to > a.length) || (to < from)) {
throw "OutOfRange";
}
@@ -52,7 +52,7 @@ class Sort {
/**
* Sorts the list in the interval [:left:] to [:right:] (both inclusive).
*/
- static void _doSort(List a, int left, int right, int compare(a, b)) {
+ static void _doSort/*<E>*/(List/*<E>*/ a, int left, int right, int compare(dynamic /*=E*/ a, dynamic /*=E*/ b)) {
if ((right - left) <= _INSERTION_SORT_THRESHOLD) {
_insertionSort(a, left, right, compare);
} else {
@@ -60,7 +60,7 @@ class Sort {
}
}
- static void _insertionSort(List a, int left, int right, int compare(a, b)) {
+ static void _insertionSort/*<E>*/(List/*<E>*/ a, int left, int right, int compare(dynamic /*=E*/ a, dynamic /*=E*/ b)) {
for (int i = left + 1; i <= right; i++) {
var el = a[i];
int j = i;
@@ -72,9 +72,9 @@ class Sort {
}
}
- static void _dualPivotQuicksort(List a,
+ static void _dualPivotQuicksort/*<E>*/(List/*<E>*/ a,
int left, int right,
- int compare(a, b)) {
+ int compare(dynamic /*=E*/ a, dynamic /*=E*/ b)) {
assert(right - left > _INSERTION_SORT_THRESHOLD);
// Compute the two pivots by looking at 5 elements.
« 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