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

Side by Side Diff: runtime/lib/array_patch.dart

Issue 11417051: Make List an abstract class. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebase Created 8 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/tests/vm/dart/isolate_mirror_local_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 // Note that the optimizing compiler depends on the algorithm which 5 // Note that the optimizing compiler depends on the algorithm which
6 // returns a _GrowableObjectArray if length is null, otherwise returns 6 // returns a _GrowableObjectArray if length is null, otherwise returns
7 // fixed size array. 7 // fixed size array.
8 patch class _ListImpl<E> { 8 patch class List<E> {
9 /* patch */ factory List([int length = null]) { 9 /* patch */ factory List([int length = null]) {
10 if (length == null) { 10 if (length == null) {
11 return new _GrowableObjectArray<E>(); 11 return new _GrowableObjectArray<E>();
12 } else { 12 } else {
13 return new _ObjectArray<E>(length); 13 return new _ObjectArray<E>(length);
14 } 14 }
15 } 15 }
16 16
17 /* patch */ factory List.from(Iterable<E> other) {
18 _GrowableObjectArray<E> list = new _GrowableObjectArray<E>();
19 for (final e in other) {
20 list.add(e);
21 }
22 return list;
23 }
24
25 // Factory constructing a mutable List from a parser generated List literal. 17 // Factory constructing a mutable List from a parser generated List literal.
26 // [elements] contains elements that are already type checked. 18 // [elements] contains elements that are already type checked.
27 factory List._fromLiteral(List elements) { 19 factory List._fromLiteral(List elements) {
28 var list = new List<E>(); 20 var list = new List<E>();
29 if (elements.length > 0) { 21 if (elements.length > 0) {
30 list._setData(elements); 22 list._setData(elements);
31 list.length = elements.length; 23 list.length = elements.length;
32 } 24 }
33 return list; 25 return list;
34 } 26 }
35 } 27 }
OLDNEW
« no previous file with comments | « no previous file | runtime/tests/vm/dart/isolate_mirror_local_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698