Index: sdk/lib/collection/list.dart |
diff --git a/sdk/lib/collection/list.dart b/sdk/lib/collection/list.dart |
index b81b8dd7c11fc2180336f577443e4a92fe3b66d7..b0c2cae45d9aa4387b735261cb5086c33517cf48 100644 |
--- a/sdk/lib/collection/list.dart |
+++ b/sdk/lib/collection/list.dart |
@@ -274,10 +274,8 @@ abstract class ListMixin<E> implements List<E> { |
_filter(this, test, true); |
} |
- static void _filter(List source, |
- bool test(var element), |
- bool retainMatching) { |
- List retained = []; |
+ void _filter(List source, bool test(var element), bool retainMatching) { |
Jennifer Messerly
2017/02/28 18:36:34
I also made the change you suggested here:
https:/
|
+ List<E> retained = <E>[]; |
int length = source.length; |
for (int i = 0; i < length; i++) { |
var element = source[i]; |
@@ -308,11 +306,12 @@ abstract class ListMixin<E> implements List<E> { |
} |
void sort([int compare(E a, E b)]) { |
- if (compare == null) { |
- Sort.sort(this, Comparable.compare); |
- } else { |
- Sort.sort(this, compare); |
- } |
+ Sort.sort(this, compare ?? _compareAny); |
+ } |
+ |
+ static int _compareAny(a, b) { |
+ // In strong mode this requires a cast to ensure `a` and `b` are Comparable. |
Lasse Reichstein Nielsen
2017/02/28 07:05:56
Confusing comment - I don't see any cast?
Jennifer Messerly
2017/02/28 18:36:35
Ah thanks! will clarify. The cast is added implici
|
+ return Comparable.compare(a, b); |
} |
void shuffle([Random random]) { |