Chromium Code Reviews| 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; |