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

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

Issue 11801023: Cleanups. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/lib/double.cc » ('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 List<E> { 8 patch class List<E> {
9 /* patch */ factory List([int length = 0]) { 9 /* patch */ factory List([int length = 0]) {
10 if (length is! int || length < 0) { 10 if ((length is! int) || (length < 0)) {
11 throw new ArgumentError("Length must be a positive integer: $length."); 11 throw new ArgumentError("Length must be a positive integer: $length.");
12 } 12 }
13 _GrowableObjectArray<E> result = new _GrowableObjectArray<E>(); 13 _GrowableObjectArray<E> result = new _GrowableObjectArray<E>();
14 result.length = length; 14 result.length = length;
15 return result; 15 return result;
16 } 16 }
17 17
18 /* patch */ factory List.fixedLength(int length, {E fill: null}) { 18 /* patch */ factory List.fixedLength(int length, {E fill: null}) {
19 if (length is! int || length < 0) { 19 if ((length is! int) || (length < 0)) {
20 throw new ArgumentError("Length must be a positive integer: $length."); 20 throw new ArgumentError("Length must be a positive integer: $length.");
21 } 21 }
22 _ObjectArray<E> result = new _ObjectArray<E>(length); 22 _ObjectArray<E> result = new _ObjectArray<E>(length);
23 if (fill != null) { 23 if (fill != null) {
24 for (int i = 0; i < length; i++) { 24 for (int i = 0; i < length; i++) {
25 result[i] = fill; 25 result[i] = fill;
26 } 26 }
27 } 27 }
28 return result; 28 return result;
29 } 29 }
30 30
31 /* patch */ factory List.filled(int length, E fill) { 31 /* patch */ factory List.filled(int length, E fill) {
32 if (length is! int || length < 0) { 32 if ((length is! int) || (length < 0)) {
33 throw new ArgumentError("Length must be a positive integer: $length."); 33 throw new ArgumentError("Length must be a positive integer: $length.");
34 } 34 }
35 _GrowableObjectArray<E> result = 35 _GrowableObjectArray<E> result =
36 new _GrowableObjectArray<E>.withCapacity(length < 4 ? 4 : length); 36 new _GrowableObjectArray<E>.withCapacity(length < 4 ? 4 : length);
37 if (length != 0) { 37 result.length = length;
38 result.length = length; 38 if (fill != null) {
39 if (fill != null) { 39 for (int i = 0; i < length; i++) {
40 for (int i = 0; i < length; i++) { 40 result[i] = fill;
41 result[i] = fill;
42 }
43 } 41 }
44 } 42 }
45 return result; 43 return result;
46 } 44 }
47 45
48 // Factory constructing a mutable List from a parser generated List literal. 46 // Factory constructing a mutable List from a parser generated List literal.
49 // [elements] contains elements that are already type checked. 47 // [elements] contains elements that are already type checked.
50 factory List._fromLiteral(List elements) { 48 factory List._fromLiteral(List elements) {
51 var list = new List<E>(); 49 var list = new List<E>();
52 if (elements.length > 0) { 50 if (elements.length > 0) {
53 list._setData(elements); 51 list._setData(elements);
54 list.length = elements.length; 52 list.length = elements.length;
55 } 53 }
56 return list; 54 return list;
57 } 55 }
58 } 56 }
OLDNEW
« no previous file with comments | « no previous file | runtime/lib/double.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698