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

Unified Diff: runtime/lib/growable_array.dart

Issue 873863002: Improve performance of addAll for internallt known lists. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/growable_array.dart
===================================================================
--- runtime/lib/growable_array.dart (revision 43149)
+++ runtime/lib/growable_array.dart (working copy)
@@ -152,7 +152,12 @@
void addAll(Iterable<T> iterable) {
var len = length;
- if (iterable is EfficientLength) {
+ final cid = ClassID.getID(iterable);
+ final isVMList =
+ (cid == ClassID.cidArray) ||
+ (cid == ClassID.cidGrowableObjectArray) ||
+ (cid == ClassID.cidImmutableArray);
Lasse Reichstein Nielsen 2015/01/27 15:13:57 Would it be worth it to recognize growable list as
srdjan 2015/01/29 17:42:19 I think so, but we would need to move it here sinc
+ if (isVMList || (iterable is EfficientLength)) {
var cap = _capacity;
// Pregrow if we know iterable.length.
var iterLen = iterable.length;
@@ -163,6 +168,16 @@
} while (newLen > cap);
_grow(cap);
}
+ if (isVMList) {
+ if (identical(iterable, this)) {
+ throw new ConcurrentModificationError(this);
Lasse Reichstein Nielsen 2015/01/27 15:13:57 This does change behavior (it now throws before ad
srdjan 2015/01/29 17:42:19 I do not understand. 'this' is always GrowableObje
+ }
+ this._setLength(newLen);
+ for (int i = 0; i < iterLen; i++) {
+ this[len++] = iterable[i];
+ }
+ return;
+ }
}
Iterator it = iterable.iterator;
if (!it.moveNext()) return;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698