From 127b419fc158446fc5a22eef9a6287b383d42c65 Mon Sep 17 00:00:00 2001 From: Stephen Adams Date: Thu, 22 Sep 2016 10:36:16 -0700 Subject: [PATCH] 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 . --- sdk/lib/internal/iterable.dart | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sdk/lib/internal/iterable.dart b/sdk/lib/internal/iterable.dart index 2bedb48e646..0e7b171e260 100644 --- a/sdk/lib/internal/iterable.dart +++ b/sdk/lib/internal/iterable.dart @@ -426,6 +426,10 @@ class WhereIterable extends Iterable { WhereIterable(this._iterable, bool this._f(E element)); Iterator get iterator => new WhereIterator(_iterable.iterator, _f); + + // Specialization of [Iterable.map] to non-EfficientLength. + Iterable/**/ map/**/(/*=T*/ f(E element)) => + new MappedIterable._(this, f); } class WhereIterator extends Iterator {