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

Unified Diff: sdk/lib/html/dart2js/html_dart2js.dart

Issue 11414069: Make mappedBy lazy. (Closed) Base URL: https://dart.googlecode.com/svn/experimental/lib_v2/dart
Patch Set: Reupload due to error. Created 8 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: sdk/lib/html/dart2js/html_dart2js.dart
diff --git a/sdk/lib/html/dart2js/html_dart2js.dart b/sdk/lib/html/dart2js/html_dart2js.dart
index 2208c688c07083da9d491e33d44c6a4cad135871..b6b08ca5d4992d8a9835b319c787eb7ee1ea89d3 100644
--- a/sdk/lib/html/dart2js/html_dart2js.dart
+++ b/sdk/lib/html/dart2js/html_dart2js.dart
@@ -2,7 +2,7 @@ library html;
import 'dart:async';
import 'dart:isolate';
-import 'dart:json';
+import 'dart:json' as json;
import 'dart:svg' as svg;
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
@@ -5336,7 +5336,7 @@ class DOMMimeTypeArray implements JavaScriptIndexingBehavior, List<DOMMimeType>
void forEach(void f(DOMMimeType element)) => _Collections.forEach(this, f);
- Collection mappedBy(f(DOMMimeType element)) => _Collections.mappedBy(this, [], f);
+ Iterable mappedBy(f(DOMMimeType element)) => new MappedIterable(this, f);
Collection<DOMMimeType> where(bool f(DOMMimeType element)) =>
_Collections.where(this, <DOMMimeType>[], f);
@@ -5475,7 +5475,7 @@ class DOMPluginArray implements JavaScriptIndexingBehavior, List<DOMPlugin> nati
void forEach(void f(DOMPlugin element)) => _Collections.forEach(this, f);
- Collection mappedBy(f(DOMPlugin element)) => _Collections.mappedBy(this, [], f);
+ Iterable mappedBy(f(DOMPlugin element)) => new MappedIterable(this, f);
Collection<DOMPlugin> where(bool f(DOMPlugin element)) =>
_Collections.where(this, <DOMPlugin>[], f);
@@ -6766,13 +6766,7 @@ class _ChildrenElementList implements List {
return false;
}
- Collection mappedBy(f(Element element)) {
- final out = [];
- for (Element el in this) {
- out.add(f(el));
- }
- return out;
- }
+ Iterable mappedBy(f(Element element)) => new MappedIterable(this, f);
bool get isEmpty {
return _element.$dom_firstElementChild == null;
@@ -6883,13 +6877,7 @@ class _FrozenElementList implements List {
}
}
- Collection mappedBy(f(Element element)) {
- final out = [];
- for (Element el in this) {
- out.add(f(el));
- }
- return out;
- }
+ Iterable mappedBy(f(Element element)) => new MappedIterable(this, f);
List<Element> where(bool f(Element element)) {
final out = [];
@@ -8628,7 +8616,7 @@ class Float32Array extends ArrayBufferView implements JavaScriptIndexingBehavior
void forEach(void f(num element)) => _Collections.forEach(this, f);
- Collection mappedBy(f(num element)) => _Collections.mappedBy(this, [], f);
+ Iterable mappedBy(f(num element)) => new MappedIterable(this, f);
Collection<num> where(bool f(num element)) =>
_Collections.where(this, <num>[], f);
@@ -8737,7 +8725,7 @@ class Float64Array extends ArrayBufferView implements JavaScriptIndexingBehavior
void forEach(void f(num element)) => _Collections.forEach(this, f);
- Collection mappedBy(f(num element)) => _Collections.mappedBy(this, [], f);
+ Iterable mappedBy(f(num element)) => new MappedIterable(this, f);
Collection<num> where(bool f(num element)) =>
_Collections.where(this, <num>[], f);
@@ -9103,7 +9091,7 @@ class HTMLAllCollection implements JavaScriptIndexingBehavior, List<Node> native
void forEach(void f(Node element)) => _Collections.forEach(this, f);
- Collection mappedBy(f(Node element)) => _Collections.mappedBy(this, [], f);
+ Iterable mappedBy(f(Node element)) => new MappedIterable(this, f);
Collection<Node> where(bool f(Node element)) =>
_Collections.where(this, <Node>[], f);
@@ -9206,7 +9194,7 @@ class HTMLCollection implements JavaScriptIndexingBehavior, List<Node> native "*
void forEach(void f(Node element)) => _Collections.forEach(this, f);
- Collection mappedBy(f(Node element)) => _Collections.mappedBy(this, [], f);
+ Iterable mappedBy(f(Node element)) => new MappedIterable(this, f);
Collection<Node> where(bool f(Node element)) =>
_Collections.where(this, <Node>[], f);
@@ -10774,7 +10762,7 @@ class Int16Array extends ArrayBufferView implements JavaScriptIndexingBehavior,
void forEach(void f(int element)) => _Collections.forEach(this, f);
- Collection mappedBy(f(int element)) => _Collections.mappedBy(this, [], f);
+ Iterable mappedBy(f(int element)) => new MappedIterable(this, f);
Collection<int> where(bool f(int element)) =>
_Collections.where(this, <int>[], f);
@@ -10883,7 +10871,7 @@ class Int32Array extends ArrayBufferView implements JavaScriptIndexingBehavior,
void forEach(void f(int element)) => _Collections.forEach(this, f);
- Collection mappedBy(f(int element)) => _Collections.mappedBy(this, [], f);
+ Iterable mappedBy(f(int element)) => new MappedIterable(this, f);
Collection<int> where(bool f(int element)) =>
_Collections.where(this, <int>[], f);
@@ -10992,7 +10980,7 @@ class Int8Array extends ArrayBufferView implements JavaScriptIndexingBehavior, L
void forEach(void f(int element)) => _Collections.forEach(this, f);
- Collection mappedBy(f(int element)) => _Collections.mappedBy(this, [], f);
+ Iterable mappedBy(f(int element)) => new MappedIterable(this, f);
Collection<int> where(bool f(int element)) =>
_Collections.where(this, <int>[], f);
@@ -13142,7 +13130,7 @@ class NamedNodeMap implements JavaScriptIndexingBehavior, List<Node> native "*Na
void forEach(void f(Node element)) => _Collections.forEach(this, f);
- Collection mappedBy(f(Node element)) => _Collections.mappedBy(this, [], f);
+ Iterable mappedBy(f(Node element)) => new MappedIterable(this, f);
Collection<Node> where(bool f(Node element)) =>
_Collections.where(this, <Node>[], f);
@@ -13377,7 +13365,7 @@ class _ChildNodeListLazy implements List {
void forEach(void f(Node element)) => _Collections.forEach(this, f);
- Collection mappedBy(f(Node element)) => _Collections.mappedBy(this, [], f);
+ Iterable mappedBy(f(Node element)) => new MappedIterable(this, f);
Collection<Node> where(bool f(Node element)) =>
new _NodeListWrapper(_Collections.where(this, <Node>[], f));
@@ -13668,7 +13656,7 @@ class _ListWrapper<E> implements List<E> {
void forEach(void f(E element)) => _list.forEach(f);
- Collection mappedBy(f(E element)) => _list.mappedBy(f);
+ Iterable mappedBy(f(E element)) => new MappedIterable(this, f);
List<E> where(bool f(E element)) => _list.where(f);
@@ -13785,7 +13773,7 @@ class NodeList implements JavaScriptIndexingBehavior, List<Node> native "*NodeLi
void forEach(void f(Node element)) => _Collections.forEach(this, f);
- Collection mappedBy(f(Node element)) => _Collections.mappedBy(this, [], f);
+ Iterable mappedBy(f(Node element)) => new MappedIterable(this, f);
Collection<Node> where(bool f(Node element)) =>
new _NodeListWrapper(_Collections.where(this, <Node>[], f));
@@ -15458,7 +15446,7 @@ class SQLResultSetRowList implements JavaScriptIndexingBehavior, List<Map> nativ
void forEach(void f(Map element)) => _Collections.forEach(this, f);
- Collection mappedBy(f(Map element)) => _Collections.mappedBy(this, [], f);
+ Iterable mappedBy(f(Map element)) => new MappedIterable(this, f);
Collection<Map> where(bool f(Map element)) =>
_Collections.where(this, <Map>[], f);
@@ -15972,7 +15960,7 @@ class SourceBufferList extends EventTarget implements JavaScriptIndexingBehavior
void forEach(void f(SourceBuffer element)) => _Collections.forEach(this, f);
- Collection mappedBy(f(SourceBuffer element)) => _Collections.mappedBy(this, [], f);
+ Iterable mappedBy(f(SourceBuffer element)) => new MappedIterable(this, f);
Collection<SourceBuffer> where(bool f(SourceBuffer element)) =>
_Collections.where(this, <SourceBuffer>[], f);
@@ -16125,7 +16113,7 @@ class SpeechGrammarList implements JavaScriptIndexingBehavior, List<SpeechGramma
void forEach(void f(SpeechGrammar element)) => _Collections.forEach(this, f);
- Collection mappedBy(f(SpeechGrammar element)) => _Collections.mappedBy(this, [], f);
+ Iterable mappedBy(f(SpeechGrammar element)) => new MappedIterable(this, f);
Collection<SpeechGrammar> where(bool f(SpeechGrammar element)) =>
_Collections.where(this, <SpeechGrammar>[], f);
@@ -17144,7 +17132,7 @@ class TextTrackCueList implements List<TextTrackCue>, JavaScriptIndexingBehavior
void forEach(void f(TextTrackCue element)) => _Collections.forEach(this, f);
- Collection mappedBy(f(TextTrackCue element)) => _Collections.mappedBy(this, [], f);
+ Iterable mappedBy(f(TextTrackCue element)) => new MappedIterable(this, f);
Collection<TextTrackCue> where(bool f(TextTrackCue element)) =>
_Collections.where(this, <TextTrackCue>[], f);
@@ -17250,7 +17238,7 @@ class TextTrackList extends EventTarget implements JavaScriptIndexingBehavior, L
void forEach(void f(TextTrack element)) => _Collections.forEach(this, f);
- Collection mappedBy(f(TextTrack element)) => _Collections.mappedBy(this, [], f);
+ Iterable mappedBy(f(TextTrack element)) => new MappedIterable(this, f);
Collection<TextTrack> where(bool f(TextTrack element)) =>
_Collections.where(this, <TextTrack>[], f);
@@ -17474,7 +17462,7 @@ class TouchList implements JavaScriptIndexingBehavior, List<Touch> native "*Touc
void forEach(void f(Touch element)) => _Collections.forEach(this, f);
- Collection mappedBy(f(Touch element)) => _Collections.mappedBy(this, [], f);
+ Iterable mappedBy(f(Touch element)) => new MappedIterable(this, f);
Collection<Touch> where(bool f(Touch element)) =>
_Collections.where(this, <Touch>[], f);
@@ -17748,7 +17736,7 @@ class Uint16Array extends ArrayBufferView implements JavaScriptIndexingBehavior,
void forEach(void f(int element)) => _Collections.forEach(this, f);
- Collection mappedBy(f(int element)) => _Collections.mappedBy(this, [], f);
+ Iterable mappedBy(f(int element)) => new MappedIterable(this, f);
Collection<int> where(bool f(int element)) =>
_Collections.where(this, <int>[], f);
@@ -17857,7 +17845,7 @@ class Uint32Array extends ArrayBufferView implements JavaScriptIndexingBehavior,
void forEach(void f(int element)) => _Collections.forEach(this, f);
- Collection mappedBy(f(int element)) => _Collections.mappedBy(this, [], f);
+ Iterable mappedBy(f(int element)) => new MappedIterable(this, f);
Collection<int> where(bool f(int element)) =>
_Collections.where(this, <int>[], f);
@@ -17966,7 +17954,7 @@ class Uint8Array extends ArrayBufferView implements JavaScriptIndexingBehavior,
void forEach(void f(int element)) => _Collections.forEach(this, f);
- Collection mappedBy(f(int element)) => _Collections.mappedBy(this, [], f);
+ Iterable mappedBy(f(int element)) => new MappedIterable(this, f);
Collection<int> where(bool f(int element)) =>
_Collections.where(this, <int>[], f);
@@ -20152,7 +20140,7 @@ class _CSSRuleList implements JavaScriptIndexingBehavior, List<CSSRule> native "
void forEach(void f(CSSRule element)) => _Collections.forEach(this, f);
- Collection mappedBy(f(CSSRule element)) => _Collections.mappedBy(this, [], f);
+ Iterable mappedBy(f(CSSRule element)) => new MappedIterable(this, f);
Collection<CSSRule> where(bool f(CSSRule element)) =>
_Collections.where(this, <CSSRule>[], f);
@@ -20249,7 +20237,7 @@ class _CSSValueList extends CSSValue implements List<CSSValue>, JavaScriptIndexi
void forEach(void f(CSSValue element)) => _Collections.forEach(this, f);
- Collection mappedBy(f(CSSValue element)) => _Collections.mappedBy(this, [], f);
+ Iterable mappedBy(f(CSSValue element)) => new MappedIterable(this, f);
Collection<CSSValue> where(bool f(CSSValue element)) =>
_Collections.where(this, <CSSValue>[], f);
@@ -20346,7 +20334,7 @@ class _ClientRectList implements JavaScriptIndexingBehavior, List<ClientRect> na
void forEach(void f(ClientRect element)) => _Collections.forEach(this, f);
- Collection mappedBy(f(ClientRect element)) => _Collections.mappedBy(this, [], f);
+ Iterable mappedBy(f(ClientRect element)) => new MappedIterable(this, f);
Collection<ClientRect> where(bool f(ClientRect element)) =>
_Collections.where(this, <ClientRect>[], f);
@@ -20452,7 +20440,7 @@ class _DOMStringList implements JavaScriptIndexingBehavior, List<String> native
void forEach(void f(String element)) => _Collections.forEach(this, f);
- Collection mappedBy(f(String element)) => _Collections.mappedBy(this, [], f);
+ Iterable mappedBy(f(String element)) => new MappedIterable(this, f);
Collection<String> where(bool f(String element)) =>
_Collections.where(this, <String>[], f);
@@ -20874,7 +20862,7 @@ class _EntryArray implements JavaScriptIndexingBehavior, List<Entry> native "*En
void forEach(void f(Entry element)) => _Collections.forEach(this, f);
- Collection mappedBy(f(Entry element)) => _Collections.mappedBy(this, [], f);
+ Iterable mappedBy(f(Entry element)) => new MappedIterable(this, f);
Collection<Entry> where(bool f(Entry element)) =>
_Collections.where(this, <Entry>[], f);
@@ -20971,7 +20959,7 @@ class _EntryArraySync implements JavaScriptIndexingBehavior, List<EntrySync> nat
void forEach(void f(EntrySync element)) => _Collections.forEach(this, f);
- Collection mappedBy(f(EntrySync element)) => _Collections.mappedBy(this, [], f);
+ Iterable mappedBy(f(EntrySync element)) => new MappedIterable(this, f);
Collection<EntrySync> where(bool f(EntrySync element)) =>
_Collections.where(this, <EntrySync>[], f);
@@ -21077,7 +21065,7 @@ class _FileList implements JavaScriptIndexingBehavior, List<File> native "*FileL
void forEach(void f(File element)) => _Collections.forEach(this, f);
- Collection mappedBy(f(File element)) => _Collections.mappedBy(this, [], f);
+ Iterable mappedBy(f(File element)) => new MappedIterable(this, f);
Collection<File> where(bool f(File element)) =>
_Collections.where(this, <File>[], f);
@@ -21203,7 +21191,7 @@ class _GamepadList implements JavaScriptIndexingBehavior, List<Gamepad> native "
void forEach(void f(Gamepad element)) => _Collections.forEach(this, f);
- Collection mappedBy(f(Gamepad element)) => _Collections.mappedBy(this, [], f);
+ Iterable mappedBy(f(Gamepad element)) => new MappedIterable(this, f);
Collection<Gamepad> where(bool f(Gamepad element)) =>
_Collections.where(this, <Gamepad>[], f);
@@ -21353,7 +21341,7 @@ class _MediaStreamList implements JavaScriptIndexingBehavior, List<MediaStream>
void forEach(void f(MediaStream element)) => _Collections.forEach(this, f);
- Collection mappedBy(f(MediaStream element)) => _Collections.mappedBy(this, [], f);
+ Iterable mappedBy(f(MediaStream element)) => new MappedIterable(this, f);
Collection<MediaStream> where(bool f(MediaStream element)) =>
_Collections.where(this, <MediaStream>[], f);
@@ -21613,7 +21601,7 @@ class _SpeechInputResultList implements JavaScriptIndexingBehavior, List<SpeechI
void forEach(void f(SpeechInputResult element)) => _Collections.forEach(this, f);
- Collection mappedBy(f(SpeechInputResult element)) => _Collections.mappedBy(this, [], f);
+ Iterable mappedBy(f(SpeechInputResult element)) => new MappedIterable(this, f);
Collection<SpeechInputResult> where(bool f(SpeechInputResult element)) =>
_Collections.where(this, <SpeechInputResult>[], f);
@@ -21719,7 +21707,7 @@ class _SpeechRecognitionResultList implements JavaScriptIndexingBehavior, List<S
void forEach(void f(SpeechRecognitionResult element)) => _Collections.forEach(this, f);
- Collection mappedBy(f(SpeechRecognitionResult element)) => _Collections.mappedBy(this, [], f);
+ Iterable mappedBy(f(SpeechRecognitionResult element)) => new MappedIterable(this, f);
Collection<SpeechRecognitionResult> where(bool f(SpeechRecognitionResult element)) =>
_Collections.where(this, <SpeechRecognitionResult>[], f);
@@ -21816,7 +21804,7 @@ class _StyleSheetList implements JavaScriptIndexingBehavior, List<StyleSheet> na
void forEach(void f(StyleSheet element)) => _Collections.forEach(this, f);
- Collection mappedBy(f(StyleSheet element)) => _Collections.mappedBy(this, [], f);
+ Iterable mappedBy(f(StyleSheet element)) => new MappedIterable(this, f);
Collection<StyleSheet> where(bool f(StyleSheet element)) =>
_Collections.where(this, <StyleSheet>[], f);
@@ -21937,7 +21925,7 @@ class _WebKitAnimationList implements JavaScriptIndexingBehavior, List<Animation
void forEach(void f(Animation element)) => _Collections.forEach(this, f);
- Collection mappedBy(f(Animation element)) => _Collections.mappedBy(this, [], f);
+ Iterable mappedBy(f(Animation element)) => new MappedIterable(this, f);
Collection<Animation> where(bool f(Animation element)) =>
_Collections.where(this, <Animation>[], f);
@@ -22097,7 +22085,7 @@ abstract class CssClassSet implements Set<String> {
readClasses().forEach(f);
}
- Collection mappedBy(f(String element)) => readClasses().mappedBy(f);
+ Iterable mappedBy(f(String element)) => readClasses().mappedBy(f);
Collection<String> where(bool f(String element)) => readClasses().where(f);
@@ -22302,7 +22290,7 @@ class FilteredElementList implements List {
return result;
}
- Collection mappedBy(f(Element element)) => _filtered.mappedBy(f);
+ Iterable mappedBy(f(Element element)) => _filtered.mappedBy(f);
Collection<Element> where(bool f(Element element)) => _filtered.where(f);
bool every(bool f(Element element)) => _filtered.every(f);
bool some(bool f(Element element)) => _filtered.some(f);
@@ -23137,13 +23125,8 @@ class _Collections {
}
}
- static List mappedBy(Iterable<Object> source,
- List<Object> destination,
- f(o)) {
- for (final e in source) {
- destination.add(f(e));
- }
- return destination;
+ static Iterable mappedBy(Iterable<Object> source, f(o)) {
+ return new MappedIterable(source, f);
}
static bool some(Iterable<Object> iterable, bool f(Object o)) {

Powered by Google App Engine
This is Rietveld 408576698