| Index: sdk/lib/internal/iterable.dart
|
| diff --git a/sdk/lib/internal/iterable.dart b/sdk/lib/internal/iterable.dart
|
| index 47c94f8b0be8975c60745e36a5f9440922feae5b..e783ea092acc7b88dfe2ff8bcc960a82e70d0ae9 100644
|
| --- a/sdk/lib/internal/iterable.dart
|
| +++ b/sdk/lib/internal/iterable.dart
|
| @@ -320,27 +320,30 @@ class SubListIterable<E> extends ListIterable<E> {
|
| */
|
| class ListIterator<E> implements Iterator<E> {
|
| final Iterable<E> _iterable;
|
| - final int _length;
|
| + final int _originalLength;
|
| int _index;
|
| E _current;
|
|
|
| ListIterator(Iterable<E> iterable)
|
| - : _iterable = iterable, _length = iterable.length, _index = 0;
|
| + : _iterable = iterable, _originalLength = iterable.length, _index = 0;
|
|
|
| E get current => _current;
|
|
|
| bool moveNext() {
|
| - int length = _iterable.length;
|
| - if (_length != length) {
|
| - throw new ConcurrentModificationError(_iterable);
|
| + // Check for concurrent modifiction at each step in checked mode.
|
| + assert((_originalLength == _iterable.length) ||
|
| + (throw new ConcurrentModificationError(_iterable)));
|
| + if (_index < _iterable.length) {
|
| + _current = _iterable.elementAt(_index);
|
| + _index++;
|
| + return true;
|
| }
|
| - if (_index >= length) {
|
| - _current = null;
|
| - return false;
|
| + // Check for concurrent modification only at the end in production mode.
|
| + if (_originalLength != _iterable.length) {
|
| + throw new ConcurrentModificationError(_iterable);
|
| }
|
| - _current = _iterable.elementAt(_index);
|
| - _index++;
|
| - return true;
|
| + _current = null;
|
| + return false;
|
| }
|
| }
|
|
|
|
|