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

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

Issue 2751423005: Run dartfmt on all files under runtime. (Closed)
Patch Set: Run dartfmt on all files under runtime. Created 3 years, 9 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 unified diff | Download patch
« no previous file with comments | « runtime/lib/array.dart ('k') | runtime/lib/async_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
11 const _GROWABLE_ARRAY_MARKER = const _GrowableArrayMarker(); 11 const _GROWABLE_ARRAY_MARKER = const _GrowableArrayMarker();
12 12
13 @patch class List<E> { 13 @patch
14 @patch factory List([int length]) = List<E>._internal; 14 class List<E> {
15 @patch
16 factory List([int length]) = List<E>._internal;
15 17
16 @patch factory List.filled(int length, E fill, {bool growable: false}) { 18 @patch
19 factory List.filled(int length, E fill, {bool growable: false}) {
17 // All error handling on the length parameter is done at the implementation 20 // All error handling on the length parameter is done at the implementation
18 // of new _List. 21 // of new _List.
19 var result = growable ? new _GrowableList<E>(length) : new _List<E>(length); 22 var result = growable ? new _GrowableList<E>(length) : new _List<E>(length);
20 if (fill != null) { 23 if (fill != null) {
21 for (int i = 0; i < length; i++) { 24 for (int i = 0; i < length; i++) {
22 result[i] = fill; 25 result[i] = fill;
23 } 26 }
24 } 27 }
25 return result; 28 return result;
26 } 29 }
27 30
28 @patch factory List.from(Iterable elements, { bool growable: true }) { 31 @patch
32 factory List.from(Iterable elements, {bool growable: true}) {
29 if (elements is EfficientLengthIterable) { 33 if (elements is EfficientLengthIterable) {
30 int length = elements.length; 34 int length = elements.length;
31 var list = growable ? new _GrowableList<E>(length) : new _List<E>(length); 35 var list = growable ? new _GrowableList<E>(length) : new _List<E>(length);
32 if (length > 0) { // Avoid creating iterator unless necessary. 36 if (length > 0) {
37 // Avoid creating iterator unless necessary.
33 int i = 0; 38 int i = 0;
34 for (var element in elements) { list[i++] = element; } 39 for (var element in elements) {
40 list[i++] = element;
41 }
35 } 42 }
36 return list; 43 return list;
37 } 44 }
38 List<E> list = new _GrowableList<E>(0); 45 List<E> list = new _GrowableList<E>(0);
39 for (E e in elements) { 46 for (E e in elements) {
40 list.add(e); 47 list.add(e);
41 } 48 }
42 if (growable) return list; 49 if (growable) return list;
43 if (list.length == 0) { 50 if (list.length == 0) {
44 // Avoid getting an immutable list from makeListFixedLength. 51 // Avoid getting an immutable list from makeListFixedLength.
45 return new _List<E>(0); 52 return new _List<E>(0);
46 } 53 }
47 return makeListFixedLength(list); 54 return makeListFixedLength(list);
48 } 55 }
49 56
50 @patch factory List.unmodifiable(Iterable elements) { 57 @patch
58 factory List.unmodifiable(Iterable elements) {
51 List result = new List<E>.from(elements, growable: false); 59 List result = new List<E>.from(elements, growable: false);
52 return makeFixedListUnmodifiable(result); 60 return makeFixedListUnmodifiable(result);
53 } 61 }
54 62
55 // The List factory constructor redirects to this one so that we can change 63 // The List factory constructor redirects to this one so that we can change
56 // length's default value from the one in the SDK's implementation. 64 // length's default value from the one in the SDK's implementation.
57 factory List._internal([int length = _GROWABLE_ARRAY_MARKER]) { 65 factory List._internal([int length = _GROWABLE_ARRAY_MARKER]) {
58 if (identical(length, _GROWABLE_ARRAY_MARKER)) { 66 if (identical(length, _GROWABLE_ARRAY_MARKER)) {
59 return new _GrowableList<E>(0); 67 return new _GrowableList<E>(0);
60 } 68 }
61 // All error handling on the length parameter is done at the implementation 69 // All error handling on the length parameter is done at the implementation
62 // of new _List. 70 // of new _List.
63 return new _List<E>(length); 71 return new _List<E>(length);
64 } 72 }
65 73
66 // Factory constructing a mutable List from a parser generated List literal. 74 // Factory constructing a mutable List from a parser generated List literal.
67 // [elements] contains elements that are already type checked. 75 // [elements] contains elements that are already type checked.
68 factory List._fromLiteral(List elements) { 76 factory List._fromLiteral(List elements) {
69 if (elements.isEmpty) { 77 if (elements.isEmpty) {
70 return new _GrowableList<E>(0); 78 return new _GrowableList<E>(0);
71 } 79 }
72 var result = new _GrowableList<E>.withData(elements); 80 var result = new _GrowableList<E>.withData(elements);
73 result._setLength(elements.length); 81 result._setLength(elements.length);
74 return result; 82 return result;
75 } 83 }
76 } 84 }
OLDNEW
« no previous file with comments | « runtime/lib/array.dart ('k') | runtime/lib/async_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698