Add WhereIterable.map

This makes some nice code improvements for dart2js. dart2js can't
inline the MappedIterable factory constructor and specialize by
optimization, so specializing by hand removes the test "is
EfficientLength" for code like "x.where(f).map(g)".

R=lrn@google.com

Review URL: https://codereview.chromium.org/2354093002 .
This commit is contained in:
Stephen Adams 2016-09-22 10:36:16 -07:00
parent 74686371b3
commit 127b419fc1

View file

@ -426,6 +426,10 @@ class WhereIterable<E> extends Iterable<E> {
WhereIterable(this._iterable, bool this._f(E element));
Iterator<E> get iterator => new WhereIterator<E>(_iterable.iterator, _f);
// Specialization of [Iterable.map] to non-EfficientLength.
Iterable/*<T>*/ map/*<T>*/(/*=T*/ f(E element)) =>
new MappedIterable<E, dynamic/*=T*/>._(this, f);
}
class WhereIterator<E> extends Iterator<E> {