mirror of
https://github.com/dart-lang/sdk
synced 2024-09-04 16:03:44 +00:00
Use _downcast and _cast instead of "as" to reduce dart2js output size.
BUG= R=leafp@google.com Review URL: https://codereview.chromium.org/1914583002 .
This commit is contained in:
parent
14d8653ed8
commit
7fdce7a2f0
|
@ -12436,7 +12436,7 @@ class _FrozenElementList<E extends Element> extends ListBase<E>
|
|||
|
||||
int get length => _nodeList.length;
|
||||
|
||||
E operator [](int index) => _nodeList[index] as E;
|
||||
E operator [](int index) => _downcast/*<Node, E>*/(_nodeList[index]);
|
||||
|
||||
void operator []=(int index, E value) {
|
||||
throw new UnsupportedError('Cannot modify list');
|
||||
|
@ -12454,11 +12454,11 @@ class _FrozenElementList<E extends Element> extends ListBase<E>
|
|||
throw new UnsupportedError('Cannot shuffle list');
|
||||
}
|
||||
|
||||
E get first => _nodeList.first as E;
|
||||
E get first => _downcast/*<Node, E>*/(_nodeList.first);
|
||||
|
||||
E get last => _nodeList.last as E;
|
||||
E get last => _downcast/*<Node, E>*/(_nodeList.last);
|
||||
|
||||
E get single => _nodeList.single as E;
|
||||
E get single => _downcast/*<Node, E>*/(_nodeList.single);
|
||||
|
||||
CssClassSet get classes => new _MultiElementCssClassSet(this);
|
||||
|
||||
|
@ -42542,13 +42542,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);
|
||||
|
||||
|
@ -42556,7 +42556,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);
|
||||
|
@ -42578,7 +42578,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);
|
||||
|
@ -42587,8 +42587,11 @@ 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;
|
||||
// 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
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
|
|
@ -13153,7 +13153,7 @@ class _FrozenElementList<E extends Element> extends ListBase<E>
|
|||
|
||||
int get length => _nodeList.length;
|
||||
|
||||
E operator [](int index) => _nodeList[index] as E;
|
||||
E operator [](int index) => _downcast/*<Node, E>*/(_nodeList[index]);
|
||||
|
||||
void operator []=(int index, E value) {
|
||||
throw new UnsupportedError('Cannot modify list');
|
||||
|
@ -13171,11 +13171,11 @@ class _FrozenElementList<E extends Element> extends ListBase<E>
|
|||
throw new UnsupportedError('Cannot shuffle list');
|
||||
}
|
||||
|
||||
E get first => _nodeList.first as E;
|
||||
E get first => _downcast/*<Node, E>*/(_nodeList.first);
|
||||
|
||||
E get last => _nodeList.last as E;
|
||||
E get last => _downcast/*<Node, E>*/(_nodeList.last);
|
||||
|
||||
E get single => _nodeList.single as E;
|
||||
E get single => _downcast/*<Node, E>*/(_nodeList.single);
|
||||
|
||||
CssClassSet get classes => new _MultiElementCssClassSet(this);
|
||||
|
||||
|
@ -47362,13 +47362,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);
|
||||
|
||||
|
@ -47376,7 +47376,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);
|
||||
|
@ -47398,7 +47398,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);
|
||||
|
@ -47407,8 +47407,11 @@ 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;
|
||||
// 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
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
|
|
@ -635,7 +635,8 @@ Future/*<T>*/ _completeRequest/*<T>*/(Request request) {
|
|||
// TODO: make sure that completer.complete is synchronous as transactions
|
||||
// may be committed if the result is not processed immediately.
|
||||
request.onSuccess.listen((e) {
|
||||
completer.complete(request.result as dynamic/*=T*/);
|
||||
var result = _cast/*<T>*/(request.result);
|
||||
completer.complete(result);
|
||||
});
|
||||
request.onError.listen(completer.completeError);
|
||||
return completer.future;
|
||||
|
@ -1186,7 +1187,7 @@ class ObjectStore extends Interceptor {
|
|||
request.onError.listen(controller.addError);
|
||||
|
||||
request.onSuccess.listen((e) {
|
||||
var cursor = request.result as dynamic /*=T*/;
|
||||
var cursor = _cast/*<T>*/(request.result);
|
||||
if (cursor == null) {
|
||||
controller.close();
|
||||
} else {
|
||||
|
@ -1199,6 +1200,9 @@ class ObjectStore extends Interceptor {
|
|||
return controller.stream;
|
||||
}
|
||||
}
|
||||
|
||||
// ignore: STRONG_MODE_DOWN_CAST_COMPOSITE
|
||||
/*=To*/ _cast/*<To>*/(dynamic x) => x;
|
||||
// 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
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
|
|
@ -579,7 +579,8 @@ Future/*<T>*/ _completeRequest/*<T>*/(Request request) {
|
|||
// TODO: make sure that completer.complete is synchronous as transactions
|
||||
// may be committed if the result is not processed immediately.
|
||||
request.onSuccess.listen((e) {
|
||||
completer.complete(request.result as dynamic/*=T*/);
|
||||
var result = _cast/*<T>*/(request.result);
|
||||
completer.complete(result);
|
||||
});
|
||||
request.onError.listen(completer.completeError);
|
||||
return completer.future;
|
||||
|
@ -1086,7 +1087,7 @@ class ObjectStore extends DartHtmlDomObject {
|
|||
request.onError.listen(controller.addError);
|
||||
|
||||
request.onSuccess.listen((e) {
|
||||
var cursor = request.result as dynamic /*=T*/;
|
||||
var cursor = _cast/*<T>*/(request.result);
|
||||
if (cursor == null) {
|
||||
controller.close();
|
||||
} else {
|
||||
|
@ -1099,6 +1100,9 @@ class ObjectStore extends DartHtmlDomObject {
|
|||
return controller.stream;
|
||||
}
|
||||
}
|
||||
|
||||
// ignore: STRONG_MODE_DOWN_CAST_COMPOSITE
|
||||
/*=To*/ _cast/*<To>*/(dynamic x) => x;
|
||||
// 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
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -280,7 +280,7 @@ $endif
|
|||
|
||||
int get length => _nodeList.length;
|
||||
|
||||
E operator [](int index) => _nodeList[index] as E;
|
||||
E operator [](int index) => _downcast/*<Node, E>*/(_nodeList[index]);
|
||||
|
||||
void operator []=(int index, E value) {
|
||||
throw new UnsupportedError('Cannot modify list');
|
||||
|
@ -298,11 +298,11 @@ $endif
|
|||
throw new UnsupportedError('Cannot shuffle list');
|
||||
}
|
||||
|
||||
E get first => _nodeList.first as E;
|
||||
E get first => _downcast/*<Node, E>*/(_nodeList.first);
|
||||
|
||||
E get last => _nodeList.last as E;
|
||||
E get last => _downcast/*<Node, E>*/(_nodeList.last);
|
||||
|
||||
E get single => _nodeList.single as E;
|
||||
E get single => _downcast/*<Node, E>*/(_nodeList.single);
|
||||
|
||||
CssClassSet get classes => new _MultiElementCssClassSet(this);
|
||||
|
||||
|
|
|
@ -105,7 +105,8 @@ Future/*<T>*/ _completeRequest/*<T>*/(Request request) {
|
|||
// TODO: make sure that completer.complete is synchronous as transactions
|
||||
// may be committed if the result is not processed immediately.
|
||||
request.onSuccess.listen((e) {
|
||||
completer.complete(request.result as dynamic/*=T*/);
|
||||
var result = _cast/*<T>*/(request.result);
|
||||
completer.complete(result);
|
||||
});
|
||||
request.onError.listen(completer.completeError);
|
||||
return completer.future;
|
||||
|
|
|
@ -148,7 +148,7 @@ $!MEMBERS
|
|||
request.onError.listen(controller.addError);
|
||||
|
||||
request.onSuccess.listen((e) {
|
||||
var cursor = request.result as dynamic /*=T*/;
|
||||
var cursor = _cast/*<T>*/(request.result);
|
||||
if (cursor == null) {
|
||||
controller.close();
|
||||
} else {
|
||||
|
@ -161,3 +161,6 @@ $!MEMBERS
|
|||
return controller.stream;
|
||||
}
|
||||
}
|
||||
|
||||
// ignore: STRONG_MODE_DOWN_CAST_COMPOSITE
|
||||
/*=To*/ _cast/*<To>*/(dynamic x) => x;
|
||||
|
|
Loading…
Reference in a new issue