chore: kill ListWrapper.create() and .push().
These wrappers are not natively understood by ts2dart. Removing them will improve Dart2JS compilation due to fewer megamorphic calls to List functions. It also makes Angular code more succinct and improves type safety in Angular due to better type inference of the Array component type. This change exposed several bugs in Angular.
This commit is contained in:
@ -342,9 +342,9 @@ export class ApplicationRef {
|
||||
function _createAppInjector(appComponentType: Type, bindings: List<Type | Binding | List<any>>,
|
||||
zone: NgZone): Injector {
|
||||
if (isBlank(_rootInjector)) _rootInjector = Injector.resolveAndCreate(_rootBindings);
|
||||
var mergedBindings = isPresent(bindings) ?
|
||||
ListWrapper.concat(_injectorBindings(appComponentType), bindings) :
|
||||
_injectorBindings(appComponentType);
|
||||
ListWrapper.push(mergedBindings, bind(NgZone).toValue(zone));
|
||||
var mergedBindings: any[] =
|
||||
isPresent(bindings) ? ListWrapper.concat(_injectorBindings(appComponentType), bindings) :
|
||||
_injectorBindings(appComponentType);
|
||||
mergedBindings.push(bind(NgZone).toValue(zone));
|
||||
return _rootInjector.resolveAndCreateChild(mergedBindings);
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ export class BaseQueryList<T> {
|
||||
}
|
||||
|
||||
add(obj) {
|
||||
ListWrapper.push(this._results, obj);
|
||||
this._results.push(obj);
|
||||
this._dirty = true;
|
||||
}
|
||||
|
||||
@ -33,7 +33,7 @@ export class BaseQueryList<T> {
|
||||
}
|
||||
}
|
||||
|
||||
onChange(callback) { ListWrapper.push(this._callbacks, callback); }
|
||||
onChange(callback) { this._callbacks.push(callback); }
|
||||
|
||||
removeCallback(callback) { ListWrapper.remove(this._callbacks, callback); }
|
||||
|
||||
|
@ -187,8 +187,7 @@ export class Compiler {
|
||||
(nestedPv: AppProtoView) => { elementBinder.nestedProtoView = nestedPv; };
|
||||
var nestedCall = this._compile(nestedComponent);
|
||||
if (isPromise(nestedCall)) {
|
||||
ListWrapper.push(nestedPVPromises,
|
||||
(<Promise<AppProtoView>>nestedCall).then(elementBinderDone));
|
||||
nestedPVPromises.push((<Promise<AppProtoView>>nestedCall).then(elementBinderDone));
|
||||
} else {
|
||||
elementBinderDone(<AppProtoView>nestedCall);
|
||||
}
|
||||
@ -206,7 +205,7 @@ export class Compiler {
|
||||
ListWrapper.forEach(protoViews, (protoView) => {
|
||||
ListWrapper.forEach(protoView.elementBinders, (elementBinder) => {
|
||||
if (isPresent(elementBinder.componentDirective)) {
|
||||
ListWrapper.push(componentElementBinders, elementBinder);
|
||||
componentElementBinders.push(elementBinder);
|
||||
}
|
||||
});
|
||||
});
|
||||
@ -254,7 +253,7 @@ export class Compiler {
|
||||
if (isArray(item)) {
|
||||
this._flattenList(item, out);
|
||||
} else {
|
||||
ListWrapper.push(out, item);
|
||||
out.push(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -154,7 +154,7 @@ export class TreeNode<T extends TreeNode<any>> {
|
||||
var res = [];
|
||||
var child = this._head;
|
||||
while (child != null) {
|
||||
ListWrapper.push(res, child);
|
||||
res.push(child);
|
||||
child = child._next;
|
||||
}
|
||||
return res;
|
||||
@ -285,7 +285,7 @@ export class DirectiveBinding extends ResolvedBinding {
|
||||
var readAttributes = [];
|
||||
ListWrapper.forEach(deps, (dep) => {
|
||||
if (isPresent(dep.attributeName)) {
|
||||
ListWrapper.push(readAttributes, dep.attributeName);
|
||||
readAttributes.push(dep.attributeName);
|
||||
}
|
||||
});
|
||||
return readAttributes;
|
||||
@ -357,10 +357,9 @@ export class BindingData {
|
||||
if (!(this.binding instanceof DirectiveBinding)) return [];
|
||||
var res = [];
|
||||
var db = <DirectiveBinding>this.binding;
|
||||
MapWrapper.forEach(
|
||||
db.hostActions,
|
||||
(actionExpression, actionName) => {ListWrapper.push(
|
||||
res, new HostActionAccessor(actionExpression, reflector.getter(actionName)))});
|
||||
MapWrapper.forEach(db.hostActions, (actionExpression, actionName) => {
|
||||
res.push(new HostActionAccessor(actionExpression, reflector.getter(actionName)));
|
||||
});
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@ -409,8 +408,8 @@ export class ProtoElementInjector {
|
||||
bd: List<BindingData>,
|
||||
firstBindingIsComponent: boolean) {
|
||||
ListWrapper.forEach(dirBindings, dirBinding => {
|
||||
ListWrapper.push(bd, ProtoElementInjector._createBindingData(
|
||||
firstBindingIsComponent, dirBinding, dirBindings, dirBinding));
|
||||
bd.push(ProtoElementInjector._createBindingData(firstBindingIsComponent, dirBinding,
|
||||
dirBindings, dirBinding));
|
||||
});
|
||||
}
|
||||
|
||||
@ -425,9 +424,9 @@ export class ProtoElementInjector {
|
||||
`Multiple directives defined the same host injectable: "${stringify(b.key.token)}"`);
|
||||
}
|
||||
MapWrapper.set(visitedIds, b.key.id, true);
|
||||
ListWrapper.push(bd, ProtoElementInjector._createBindingData(
|
||||
firstBindingIsComponent, dirBinding, dirBindings,
|
||||
ProtoElementInjector._createBinding(b)));
|
||||
bd.push(ProtoElementInjector._createBindingData(firstBindingIsComponent, dirBinding,
|
||||
dirBindings,
|
||||
ProtoElementInjector._createBinding(b)));
|
||||
});
|
||||
});
|
||||
}
|
||||
@ -442,8 +441,7 @@ export class ProtoElementInjector {
|
||||
var db = <DirectiveBinding>bindings[0];
|
||||
ListWrapper.forEach(
|
||||
db.resolvedViewInjectables,
|
||||
b => ListWrapper.push(bd,
|
||||
new BindingData(ProtoElementInjector._createBinding(b), SHADOW_DOM)));
|
||||
b => bd.push(new BindingData(ProtoElementInjector._createBinding(b), SHADOW_DOM)));
|
||||
}
|
||||
|
||||
private static _createBinding(b: ResolvedBinding) {
|
||||
@ -963,15 +961,15 @@ export class ElementInjector extends TreeNode<ElementInjector> {
|
||||
var queriesToUpdate = [];
|
||||
if (isPresent(this.parent._query0)) {
|
||||
this._pruneQueryFromTree(this.parent._query0);
|
||||
ListWrapper.push(queriesToUpdate, this.parent._query0);
|
||||
queriesToUpdate.push(this.parent._query0);
|
||||
}
|
||||
if (isPresent(this.parent._query1)) {
|
||||
this._pruneQueryFromTree(this.parent._query1);
|
||||
ListWrapper.push(queriesToUpdate, this.parent._query1);
|
||||
queriesToUpdate.push(this.parent._query1);
|
||||
}
|
||||
if (isPresent(this.parent._query2)) {
|
||||
this._pruneQueryFromTree(this.parent._query2);
|
||||
ListWrapper.push(queriesToUpdate, this.parent._query2);
|
||||
queriesToUpdate.push(this.parent._query2);
|
||||
}
|
||||
|
||||
this.remove();
|
||||
@ -1454,10 +1452,10 @@ class QueryRef {
|
||||
this.list.reset(aggregator);
|
||||
}
|
||||
|
||||
visit(inj: ElementInjector, aggregator): void {
|
||||
visit(inj: ElementInjector, aggregator: any[]): void {
|
||||
if (isBlank(inj) || !inj._hasQuery(this)) return;
|
||||
if (inj.hasDirective(this.query.directive)) {
|
||||
ListWrapper.push(aggregator, inj.get(this.query.directive));
|
||||
aggregator.push(inj.get(this.query.directive));
|
||||
}
|
||||
var child = inj._head;
|
||||
while (isPresent(child)) {
|
||||
|
@ -47,10 +47,8 @@ class BindingRecordsCreator {
|
||||
for (var elementIndex = 0; elementIndex < elementBinders.length; ++elementIndex) {
|
||||
var dirs = elementBinders[elementIndex].directives;
|
||||
for (var dirIndex = 0; dirIndex < dirs.length; ++dirIndex) {
|
||||
ListWrapper.push(
|
||||
directiveRecords,
|
||||
this._getDirectiveRecord(elementIndex, dirIndex,
|
||||
allDirectiveMetadatas[dirs[dirIndex].directiveIndex]));
|
||||
directiveRecords.push(this._getDirectiveRecord(
|
||||
elementIndex, dirIndex, allDirectiveMetadatas[dirs[dirIndex].directiveIndex]));
|
||||
}
|
||||
}
|
||||
|
||||
@ -62,15 +60,15 @@ class BindingRecordsCreator {
|
||||
if (isBlank(renderElementBinder.textBindings)) return;
|
||||
|
||||
ListWrapper.forEach(renderElementBinder.textBindings, (b) => {
|
||||
ListWrapper.push(bindings, BindingRecord.createForTextNode(b, this._textNodeIndex++));
|
||||
bindings.push(BindingRecord.createForTextNode(b, this._textNodeIndex++));
|
||||
});
|
||||
}
|
||||
|
||||
_createElementPropertyRecords(bindings: List<BindingRecord>, boundElementIndex: number,
|
||||
renderElementBinder: renderApi.ElementBinder) {
|
||||
MapWrapper.forEach(renderElementBinder.propertyBindings, (astWithSource, propertyName) => {
|
||||
ListWrapper.push(
|
||||
bindings, BindingRecord.createForElement(astWithSource, boundElementIndex, propertyName));
|
||||
|
||||
bindings.push(BindingRecord.createForElement(astWithSource, boundElementIndex, propertyName));
|
||||
});
|
||||
}
|
||||
|
||||
@ -87,18 +85,18 @@ class BindingRecordsCreator {
|
||||
// TODO: these setters should eventually be created by change detection, to make
|
||||
// it monomorphic!
|
||||
var setter = reflector.setter(propertyName);
|
||||
ListWrapper.push(bindings, BindingRecord.createForDirective(astWithSource, propertyName,
|
||||
setter, directiveRecord));
|
||||
bindings.push(
|
||||
BindingRecord.createForDirective(astWithSource, propertyName, setter, directiveRecord));
|
||||
});
|
||||
|
||||
if (directiveRecord.callOnChange) {
|
||||
ListWrapper.push(bindings, BindingRecord.createDirectiveOnChange(directiveRecord));
|
||||
bindings.push(BindingRecord.createDirectiveOnChange(directiveRecord));
|
||||
}
|
||||
if (directiveRecord.callOnInit) {
|
||||
ListWrapper.push(bindings, BindingRecord.createDirectiveOnInit(directiveRecord));
|
||||
bindings.push(BindingRecord.createDirectiveOnInit(directiveRecord));
|
||||
}
|
||||
if (directiveRecord.callOnCheck) {
|
||||
ListWrapper.push(bindings, BindingRecord.createDirectiveOnCheck(directiveRecord));
|
||||
bindings.push(BindingRecord.createDirectiveOnCheck(directiveRecord));
|
||||
}
|
||||
}
|
||||
|
||||
@ -107,8 +105,8 @@ class BindingRecordsCreator {
|
||||
// host properties
|
||||
MapWrapper.forEach(directiveBinder.hostPropertyBindings, (astWithSource, propertyName) => {
|
||||
var dirIndex = new DirectiveIndex(boundElementIndex, i);
|
||||
ListWrapper.push(
|
||||
bindings, BindingRecord.createForHostProperty(dirIndex, astWithSource, propertyName));
|
||||
|
||||
bindings.push(BindingRecord.createForHostProperty(dirIndex, astWithSource, propertyName));
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -185,8 +183,8 @@ function _collectNestedProtoViews(
|
||||
if (isBlank(result)) {
|
||||
result = [];
|
||||
}
|
||||
ListWrapper.push(result, new RenderProtoViewWithIndex(renderProtoView, result.length, parentIndex,
|
||||
boundElementIndex));
|
||||
result.push(
|
||||
new RenderProtoViewWithIndex(renderProtoView, result.length, parentIndex, boundElementIndex));
|
||||
var currentIndex = result.length - 1;
|
||||
var childBoundElementIndex = 0;
|
||||
ListWrapper.forEach(renderProtoView.elementBinders, (elementBinder) => {
|
||||
@ -266,7 +264,6 @@ function _collectNestedProtoViewsVariableNames(
|
||||
return nestedPvVariableNames;
|
||||
}
|
||||
|
||||
|
||||
function _createVariableNames(parentVariableNames, renderProtoView): List<string> {
|
||||
var res = isBlank(parentVariableNames) ? [] : ListWrapper.clone(parentVariableNames);
|
||||
MapWrapper.forEach(renderProtoView.variableBindings,
|
||||
|
@ -183,7 +183,7 @@ export class AppProtoView {
|
||||
new ElementBinder(this.elementBinders.length, parent, distanceToParent,
|
||||
protoElementInjector, directiveVariableBindings, componentDirective);
|
||||
|
||||
ListWrapper.push(this.elementBinders, elBinder);
|
||||
this.elementBinders.push(elBinder);
|
||||
return elBinder;
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,7 @@ export class AppViewManagerUtils {
|
||||
elementInjector = protoElementInjector.instantiate(parentElementInjector);
|
||||
} else {
|
||||
elementInjector = protoElementInjector.instantiate(null);
|
||||
ListWrapper.push(rootElementInjectors, elementInjector);
|
||||
rootElementInjectors.push(elementInjector);
|
||||
}
|
||||
}
|
||||
elementInjectors[binderIdx] = elementInjector;
|
||||
|
@ -34,7 +34,7 @@ export class AppViewPool {
|
||||
}
|
||||
var haveRemainingCapacity = pooledViews.length < this._poolCapacityPerProtoView;
|
||||
if (haveRemainingCapacity) {
|
||||
ListWrapper.push(pooledViews, view);
|
||||
pooledViews.push(view);
|
||||
}
|
||||
return haveRemainingCapacity;
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ export class Testability {
|
||||
|
||||
constructor() {
|
||||
this._pendingCount = 0;
|
||||
this._callbacks = ListWrapper.create();
|
||||
this._callbacks = [];
|
||||
}
|
||||
|
||||
increaseCount(delta: number = 1) {
|
||||
@ -37,7 +37,7 @@ export class Testability {
|
||||
}
|
||||
|
||||
whenStable(callback: Function) {
|
||||
ListWrapper.push(this._callbacks, callback);
|
||||
this._callbacks.push(callback);
|
||||
|
||||
if (this._pendingCount === 0) {
|
||||
this._runCallbacks();
|
||||
|
Reference in New Issue
Block a user