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

Unified Diff: tools/dom/src/WrappedList.dart

Issue 1914583002: Use _downcast and _cast instead of "as" to reduce dart2js output size. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 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
Index: tools/dom/src/WrappedList.dart
diff --git a/tools/dom/src/WrappedList.dart b/tools/dom/src/WrappedList.dart
index 4cd72260bd33423b45a0b643738576f187999898..c06e8dc923d8016355d1883c725f7ee6764dd1c6 100644
--- a/tools/dom/src/WrappedList.dart
+++ b/tools/dom/src/WrappedList.dart
@@ -30,13 +30,13 @@ class _WrappedList<E extends Node> extends ListBase<E>
// List APIs
- E operator [](int index) => _list[index] as E;
+ E operator [](int index) => _downcast/*<Node, E>*/(_list[index]);
void operator []=(int index, E value) { _list[index] = value; }
set length(int newLength) { _list.length = newLength; }
- void sort([int compare(E a, E b)]) { _list.sort((Node a, Node b) => compare(a as E, b as E)); }
+ void sort([int compare(E a, E b)]) { _list.sort((Node a, Node b) => compare(_downcast/*<Node, E>*/(a), _downcast/*<Node, E>*/(b))); }
int indexOf(Object element, [int start = 0]) => _list.indexOf(element, start);
@@ -44,7 +44,7 @@ class _WrappedList<E extends Node> extends ListBase<E>
void insert(int index, E element) => _list.insert(index, element);
- E removeAt(int index) => _list.removeAt(index) as E;
+ E removeAt(int index) => _downcast/*<Node, E>*/(_list.removeAt(index));
void setRange(int start, int end, Iterable<E> iterable, [int skipCount = 0]) {
_list.setRange(start, end, iterable, skipCount);
@@ -66,7 +66,7 @@ class _WrappedList<E extends Node> extends ListBase<E>
/**
* Iterator wrapper for _WrappedList.
*/
-class _WrappedIterator<E> implements Iterator<E> {
+class _WrappedIterator<E extends Node> implements Iterator<E> {
Iterator<Node> _iterator;
_WrappedIterator(this._iterator);
@@ -75,5 +75,8 @@ class _WrappedIterator<E> implements Iterator<E> {
return _iterator.moveNext();
}
- E get current => _iterator.current as E;
+ E get current => _downcast/*<Node, E>*/(_iterator.current);
}
+
+// ignore: STRONG_MODE_DOWN_CAST_COMPOSITE
+/*=To*/ _downcast/*<From, To extends From>*/(dynamic /*=From*/ x) => x;
« no previous file with comments | « sdk/lib/indexed_db/dartium/indexed_db_dartium.dart ('k') | tools/dom/templates/html/impl/impl_Element.darttemplate » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698