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

Side by Side Diff: sdk/lib/internal/iterable.dart

Issue 2843423002: Fix hot dynamic check in WhereIterator (Closed)
Patch Set: Created 3 years, 7 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 | « pkg/dev_compiler/lib/sdk/ddc_sdk.sum ('k') | no next file » | 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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 part of dart._internal; 5 part of dart._internal;
6 6
7 /** 7 /**
8 * Marker interface for [Iterable] subclasses that have an efficient 8 * Marker interface for [Iterable] subclasses that have an efficient
9 * [length] implementation. 9 * [length] implementation.
10 */ 10 */
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 WhereIterable(this._iterable, this._f); 422 WhereIterable(this._iterable, this._f);
423 423
424 Iterator<E> get iterator => new WhereIterator<E>(_iterable.iterator, _f); 424 Iterator<E> get iterator => new WhereIterator<E>(_iterable.iterator, _f);
425 425
426 // Specialization of [Iterable.map] to non-EfficientLengthIterable. 426 // Specialization of [Iterable.map] to non-EfficientLengthIterable.
427 Iterable<T> map<T>(T f(E element)) => new MappedIterable<E, T>._(this, f); 427 Iterable<T> map<T>(T f(E element)) => new MappedIterable<E, T>._(this, f);
428 } 428 }
429 429
430 class WhereIterator<E> extends Iterator<E> { 430 class WhereIterator<E> extends Iterator<E> {
431 final Iterator<E> _iterator; 431 final Iterator<E> _iterator;
432 final _ElementPredicate _f; 432 final _ElementPredicate<E> _f;
433 433
434 WhereIterator(this._iterator, this._f); 434 WhereIterator(this._iterator, this._f);
435 435
436 bool moveNext() { 436 bool moveNext() {
437 while (_iterator.moveNext()) { 437 while (_iterator.moveNext()) {
438 if (_f(_iterator.current)) { 438 if (_f(_iterator.current)) {
vsm 2017/04/27 13:29:28 The change above removes the dynamic check on _f h
439 return true; 439 return true;
440 } 440 }
441 } 441 }
442 return false; 442 return false;
443 } 443 }
444 444
445 E get current => _iterator.current; 445 E get current => _iterator.current;
446 } 446 }
447 447
448 typedef Iterable<T> _ExpandFunction<S, T>(S sourceElement); 448 typedef Iterable<T> _ExpandFunction<S, T>(S sourceElement);
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 * Creates errors throw by [Iterable] when the element count is wrong. 762 * Creates errors throw by [Iterable] when the element count is wrong.
763 */ 763 */
764 abstract class IterableElementError { 764 abstract class IterableElementError {
765 /** Error thrown thrown by, e.g., [Iterable.first] when there is no result. */ 765 /** Error thrown thrown by, e.g., [Iterable.first] when there is no result. */
766 static StateError noElement() => new StateError("No element"); 766 static StateError noElement() => new StateError("No element");
767 /** Error thrown by, e.g., [Iterable.single] if there are too many results. */ 767 /** Error thrown by, e.g., [Iterable.single] if there are too many results. */
768 static StateError tooMany() => new StateError("Too many elements"); 768 static StateError tooMany() => new StateError("Too many elements");
769 /** Error thrown by, e.g., [List.setRange] if there are too few elements. */ 769 /** Error thrown by, e.g., [List.setRange] if there are too few elements. */
770 static StateError tooFew() => new StateError("Too few elements"); 770 static StateError tooFew() => new StateError("Too few elements");
771 } 771 }
OLDNEW
« no previous file with comments | « pkg/dev_compiler/lib/sdk/ddc_sdk.sum ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698