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

Unified Diff: runtime/lib/array_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: Address comments. 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
« no previous file with comments | « runtime/lib/array.dart ('k') | runtime/lib/class_id.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/array_patch.dart
diff --git a/runtime/lib/array_patch.dart b/runtime/lib/array_patch.dart
index cb9ca76716f0fd7d3cbe52eca974426d918088f7..424a65110fc2ba0fba52290b3d82bfa1a10d1088 100644
--- a/runtime/lib/array_patch.dart
+++ b/runtime/lib/array_patch.dart
@@ -32,6 +32,22 @@ patch class List<E> {
return result;
}
+ /* patch */ factory List.from(Iterable other, { bool growable: true }) {
+ if (other is EfficientLength) {
+ int length = other.length;
+ var list = growable ? new _GrowableList<E>(length) : new _List<E>(length);
+ int i = 0;
+ for (var element in other) { list[i++] = element; }
+ return list;
+ }
+ List<E> list = new _GrowableList<E>(0);
+ for (E e in other) {
+ list.add(e);
+ }
+ if (growable) return list;
+ return makeListFixedLength(list);
+ }
+
// Factory constructing a mutable List from a parser generated List literal.
// [elements] contains elements that are already type checked.
factory List._fromLiteral(List elements) {
« no previous file with comments | « runtime/lib/array.dart ('k') | runtime/lib/class_id.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698