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

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

Issue 2467113003: Make EfficientLength extend Iterable. (Closed)
Patch Set: Reverted, prepare to reland. Make new test not break web-testing framework. Created 4 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
« no previous file with comments | « no previous file | runtime/lib/collection_patch.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 // The _GrowableArrayMarker class is used to signal to the List() factory 5 // The _GrowableArrayMarker class is used to signal to the List() factory
6 // whether a parameter was passed. 6 // whether a parameter was passed.
7 class _GrowableArrayMarker implements int { 7 class _GrowableArrayMarker implements int {
8 const _GrowableArrayMarker(); 8 const _GrowableArrayMarker();
9 } 9 }
10 10
(...skipping 15 matching lines...) Expand all
26 var result = growable ? new _GrowableList<E>(length) : new _List<E>(length); 26 var result = growable ? new _GrowableList<E>(length) : new _List<E>(length);
27 if (fill != null) { 27 if (fill != null) {
28 for (int i = 0; i < length; i++) { 28 for (int i = 0; i < length; i++) {
29 result[i] = fill; 29 result[i] = fill;
30 } 30 }
31 } 31 }
32 return result; 32 return result;
33 } 33 }
34 34
35 @patch factory List.from(Iterable elements, { bool growable: true }) { 35 @patch factory List.from(Iterable elements, { bool growable: true }) {
36 if (elements is EfficientLength) { 36 if (elements is EfficientLengthIterable) {
37 int length = elements.length; 37 int length = elements.length;
38 var list = growable ? new _GrowableList<E>(length) : new _List<E>(length); 38 var list = growable ? new _GrowableList<E>(length) : new _List<E>(length);
39 if (length > 0) { // Avoid creating iterator unless necessary. 39 if (length > 0) { // Avoid creating iterator unless necessary.
40 int i = 0; 40 int i = 0;
41 for (var element in elements) { list[i++] = element; } 41 for (var element in elements) { list[i++] = element; }
42 } 42 }
43 return list; 43 return list;
44 } 44 }
45 List<E> list = new _GrowableList<E>(0); 45 List<E> list = new _GrowableList<E>(0);
46 for (E e in elements) { 46 for (E e in elements) {
(...skipping 16 matching lines...) Expand all
63 // [elements] contains elements that are already type checked. 63 // [elements] contains elements that are already type checked.
64 factory List._fromLiteral(List elements) { 64 factory List._fromLiteral(List elements) {
65 if (elements.isEmpty) { 65 if (elements.isEmpty) {
66 return new _GrowableList<E>(0); 66 return new _GrowableList<E>(0);
67 } 67 }
68 var result = new _GrowableList<E>.withData(elements); 68 var result = new _GrowableList<E>.withData(elements);
69 result._setLength(elements.length); 69 result._setLength(elements.length);
70 return result; 70 return result;
71 } 71 }
72 } 72 }
OLDNEW
« no previous file with comments | « no previous file | runtime/lib/collection_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698