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

Unified Diff: sdk/lib/_collection_dev/iterable.dart

Issue 12328104: Change new List(n) to return fixed length list. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Merge to head. Created 7 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
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>();
}

Powered by Google App Engine
This is Rietveld 408576698