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

Unified Diff: sdk/lib/_internal/lib/core_patch.dart

Issue 485043002: Optimize List.toList/.sublist and List.from on lists. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Avoid calling _GrowableList.withData with empty list. Created 6 years, 4 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/_internal/lib/core_patch.dart
diff --git a/sdk/lib/_internal/lib/core_patch.dart b/sdk/lib/_internal/lib/core_patch.dart
index 75b339d9d00b9d5c0a8ed0ecacf33048b95601d4..85ab0b9246ffed5c5d9d55d3223eaf31032a5be7 100644
--- a/sdk/lib/_internal/lib/core_patch.dart
+++ b/sdk/lib/_internal/lib/core_patch.dart
@@ -254,6 +254,16 @@ class List<E> {
}
return result;
}
+
+ @patch
+ factory List.from(Iterable other, { bool growable: true }) {
+ List<E> list = new List<E>();
+ for (E e in other) {
+ list.add(e);
+ }
+ if (growable) return list;
+ return makeListFixedLength(list);
+ }
}

Powered by Google App Engine
This is Rietveld 408576698