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

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

Issue 1154263003: Revert "Make EfficientLength public, as EfficientLengthIterable." (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 6 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/collection_patch.dart ('k') | runtime/lib/immutable_map.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 class _GrowableList<T> extends ListBase<T> { 5 class _GrowableList<T> extends ListBase<T> {
6 6
7 void insert(int index, T element) { 7 void insert(int index, T element) {
8 if ((index < 0) || (index > length)) { 8 if ((index < 0) || (index > length)) {
9 throw new RangeError.range(index, 0, length); 9 throw new RangeError.range(index, 0, length);
10 } 10 }
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 this[len] = value; 150 this[len] = value;
151 } 151 }
152 152
153 void addAll(Iterable<T> iterable) { 153 void addAll(Iterable<T> iterable) {
154 var len = length; 154 var len = length;
155 final cid = ClassID.getID(iterable); 155 final cid = ClassID.getID(iterable);
156 final isVMList = 156 final isVMList =
157 (cid == ClassID.cidArray) || 157 (cid == ClassID.cidArray) ||
158 (cid == ClassID.cidGrowableObjectArray) || 158 (cid == ClassID.cidGrowableObjectArray) ||
159 (cid == ClassID.cidImmutableArray); 159 (cid == ClassID.cidImmutableArray);
160 if (isVMList || (iterable is EfficientLengthIterable)) { 160 if (isVMList || (iterable is EfficientLength)) {
161 var cap = _capacity; 161 var cap = _capacity;
162 // Pregrow if we know iterable.length. 162 // Pregrow if we know iterable.length.
163 var iterLen = iterable.length; 163 var iterLen = iterable.length;
164 var newLen = len + iterLen; 164 var newLen = len + iterLen;
165 if (newLen > cap) { 165 if (newLen > cap) {
166 do { 166 do {
167 cap *= 2; 167 cap *= 2;
168 } while (newLen > cap); 168 } while (newLen > cap);
169 _grow(cap); 169 _grow(cap);
170 } 170 }
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 result._setLength(length); 336 result._setLength(length);
337 return result; 337 return result;
338 } 338 }
339 return growable ? <T>[] : new List<T>(0); 339 return growable ? <T>[] : new List<T>(0);
340 } 340 }
341 341
342 Set<T> toSet() { 342 Set<T> toSet() {
343 return new Set<T>.from(this); 343 return new Set<T>.from(this);
344 } 344 }
345 } 345 }
OLDNEW
« no previous file with comments | « runtime/lib/collection_patch.dart ('k') | runtime/lib/immutable_map.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698