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

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

Issue 2968003004: Revert "The current growth strategy for growable arrays allocates a backing array of size 2 at (emp… (Closed)
Patch Set: Created 3 years, 5 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 | « no previous file | runtime/lib/growable_array.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 // 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 29 matching lines...) Expand all
40 list[i++] = element; 40 list[i++] = element;
41 } 41 }
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) {
47 list.add(e); 47 list.add(e);
48 } 48 }
49 if (growable) return list; 49 if (growable) return list;
50 if (list.length == 0) {
51 // Avoid getting an immutable list from makeListFixedLength.
52 return new _List<E>(0);
53 }
50 return makeListFixedLength(list); 54 return makeListFixedLength(list);
51 } 55 }
52 56
53 @patch 57 @patch
54 factory List.unmodifiable(Iterable elements) { 58 factory List.unmodifiable(Iterable elements) {
55 List result = new List<E>.from(elements, growable: false); 59 List result = new List<E>.from(elements, growable: false);
56 return makeFixedListUnmodifiable(result); 60 return makeFixedListUnmodifiable(result);
57 } 61 }
58 62
59 // 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
(...skipping 11 matching lines...) Expand all
71 // [elements] contains elements that are already type checked. 75 // [elements] contains elements that are already type checked.
72 factory List._fromLiteral(List elements) { 76 factory List._fromLiteral(List elements) {
73 if (elements.isEmpty) { 77 if (elements.isEmpty) {
74 return new _GrowableList<E>(0); 78 return new _GrowableList<E>(0);
75 } 79 }
76 var result = new _GrowableList<E>.withData(elements); 80 var result = new _GrowableList<E>.withData(elements);
77 result._setLength(elements.length); 81 result._setLength(elements.length);
78 return result; 82 return result;
79 } 83 }
80 } 84 }
OLDNEW
« no previous file with comments | « no previous file | runtime/lib/growable_array.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698