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

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

Issue 11882005: Fix performance of array literals (e.g. "[1, 2]"). Improves speed of DeltaBlue. (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/growable_array.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 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)) {
(...skipping 27 matching lines...) Expand all
38 for (int i = 0; i < length; i++) { 38 for (int i = 0; i < length; i++) {
39 result[i] = fill; 39 result[i] = fill;
40 } 40 }
41 } 41 }
42 return result; 42 return result;
43 } 43 }
44 44
45 // Factory constructing a mutable List from a parser generated List literal. 45 // Factory constructing a mutable List from a parser generated List literal.
46 // [elements] contains elements that are already type checked. 46 // [elements] contains elements that are already type checked.
47 factory List._fromLiteral(List elements) { 47 factory List._fromLiteral(List elements) {
48 var list = new List<E>(); 48 if (elements.isEmpty) {
49 if (elements.length > 0) { 49 return new _GrowableObjectArray<E>(0);
50 list._setData(elements);
51 list.length = elements.length;
52 } 50 }
53 return list; 51 var result = new _GrowableObjectArray<E>.withData(elements);
52 result._setLength(elements.length);
53 return result;
54 } 54 }
55 55
56 static void _throwArgumentError(int length) { 56 static void _throwArgumentError(int length) {
57 throw new ArgumentError("Length must be a positive integer: $length."); 57 throw new ArgumentError("Length must be a positive integer: $length.");
58 } 58 }
59 } 59 }
OLDNEW
« no previous file with comments | « no previous file | runtime/lib/growable_array.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698