Index: sdk/lib/_collection_dev/iterable.dart |
diff --git a/sdk/lib/_collection_dev/iterable.dart b/sdk/lib/_collection_dev/iterable.dart |
index f44cc89762c061dcf54012f3fe753d191e68e455..21bdbd1def05a1e93dcd61aee9d2b348d6eb5789 100644 |
--- a/sdk/lib/_collection_dev/iterable.dart |
+++ b/sdk/lib/_collection_dev/iterable.dart |
@@ -219,8 +219,13 @@ abstract class ListIterable<E> extends Iterable<E> { |
Iterable<E> takeWhile(bool test(E element)) => super.takeWhile(test); |
- List<E> toList() { |
- List<E> result = new List(length); |
+ List<E> toList({ bool growable: false }) { |
+ List<E> result; |
+ if (growable) { |
+ result = new List<E>()..length = length; |
+ } else { |
+ result = new List<E>(length); |
+ } |
for (int i = 0; i < length; i++) { |
result[i] = elementAt(i); |
} |
@@ -676,7 +681,7 @@ class EmptyIterable<E> extends Iterable<E> { |
Iterable<E> takeWhile(bool test(E element)) => this; |
- List toList() => <E>[]; |
+ List toList({ bool growable: false }) => growable ? <E>[] : new List<E>(0); |
Set toSet() => new Set<E>(); |
} |