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

Unified Diff: client/html/src/ElementWrappingImplementation.dart

Issue 9283003: Don't use _toList on FrozenElementList. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 11 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 side-by-side diff with in-line comments
Download patch
« client/html/release/htmlimpl.dart ('K') | « client/html/release/htmlimpl.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/html/src/ElementWrappingImplementation.dart
diff --git a/client/html/src/ElementWrappingImplementation.dart b/client/html/src/ElementWrappingImplementation.dart
index 8f9abb72c0912f01c9f612180b4ec7d5751087e5..243d6bf9cf48907b4061b22fb4cbd4cb52b4aa55 100644
--- a/client/html/src/ElementWrappingImplementation.dart
+++ b/client/html/src/ElementWrappingImplementation.dart
@@ -133,29 +133,34 @@ class _ChildrenElementList implements ElementList {
class FrozenElementList implements ElementList {
final _ptr;
- List<Element> _list;
FrozenElementList._wrap(this._ptr);
- List<Element> _toList() {
- if (_list == null) {
- _list = new List(_ptr.length);
- for (int i = 0, len = _ptr.length; i < len; i++) {
- _list[i] = LevelDom.wrapElement(_ptr[i]);
- }
- }
- return _list;
- }
-
Element get first() {
return this[0];
}
- void forEach(void f(Element element)) => _toList().forEach(f);
+ void forEach(void f(Element element)) {
+ for (Element el in this) {
+ f(el);
+ }
+ }
- Collection map(f(Element element)) => _toList().map(f);
+ Collection map(f(Element element)) {
+ var out = [];
+ for (Element el in this) {
+ out.add(f(el));
+ }
+ return out;
+ }
- Collection<Element> filter(bool f(Element element)) => _toList().filter(f);
+ Collection<Element> filter(bool f(Element element)) {
+ var out = [];
+ for (Element el in this) {
+ if (f(el)) out.add(el);
+ }
+ return out;
+ }
bool every(bool f(Element element)) {
for(Element element in this) {
« client/html/release/htmlimpl.dart ('K') | « client/html/release/htmlimpl.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698