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:
Martin Probst
2015-06-17 11:17:21 -07:00
parent 6af41a4543
commit c7e48350d3
88 changed files with 360 additions and 387 deletions

View File

@ -1,7 +1,6 @@
import {Directive} from 'angular2/annotations';
import {ViewContainerRef, ViewRef, ProtoViewRef} from 'angular2/core';
import {isPresent, isBlank} from 'angular2/src/facade/lang';
import {ListWrapper} from 'angular2/src/facade/collection';
/**
* The `NgFor` directive instantiates a template once per item from an iterable. The context for
@ -54,16 +53,16 @@ export class NgFor {
// TODO(rado): check if change detection can produce a change record that is
// easier to consume than current.
var recordViewTuples = [];
changes.forEachRemovedItem((removedRecord) => ListWrapper.push(
recordViewTuples, new RecordViewTuple(removedRecord, null)));
changes.forEachRemovedItem((removedRecord) =>
recordViewTuples.push(new RecordViewTuple(removedRecord, null)));
changes.forEachMovedItem((movedRecord) => ListWrapper.push(
recordViewTuples, new RecordViewTuple(movedRecord, null)));
changes.forEachMovedItem((movedRecord) =>
recordViewTuples.push(new RecordViewTuple(movedRecord, null)));
var insertTuples = NgFor.bulkRemove(recordViewTuples, this.viewContainer);
changes.forEachAddedItem(
(addedRecord) => ListWrapper.push(insertTuples, new RecordViewTuple(addedRecord, null)));
changes.forEachAddedItem((addedRecord) =>
insertTuples.push(new RecordViewTuple(addedRecord, null)));
NgFor.bulkInsert(insertTuples, this.viewContainer, this.protoViewRef);
@ -85,7 +84,7 @@ export class NgFor {
// separate moved views from removed views.
if (isPresent(tuple.record.currentIndex)) {
tuple.view = viewContainer.detach(tuple.record.previousIndex);
ListWrapper.push(movedTuples, tuple);
movedTuples.push(tuple);
} else {
viewContainer.remove(tuple.record.previousIndex);
}

View File

@ -53,7 +53,7 @@ export class NgSwitch {
constructor() {
this._valueViews = MapWrapper.create();
this._activeViews = ListWrapper.create();
this._activeViews = [];
this._useDefault = false;
}
@ -86,7 +86,7 @@ export class NgSwitch {
this._emptyAllActiveViews();
}
view.create();
ListWrapper.push(this._activeViews, view);
this._activeViews.push(view);
}
// Switch to default when there is no more active ViewContainers
@ -101,7 +101,7 @@ export class NgSwitch {
for (var i = 0; i < activeContainers.length; i++) {
activeContainers[i].destroy();
}
this._activeViews = ListWrapper.create();
this._activeViews = [];
}
_activateViews(views: List<SwitchView>): void {
@ -117,10 +117,10 @@ export class NgSwitch {
_registerView(value, view: SwitchView): void {
var views = MapWrapper.get(this._valueViews, value);
if (isBlank(views)) {
views = ListWrapper.create();
views = [];
MapWrapper.set(this._valueViews, value, views);
}
ListWrapper.push(views, view);
views.push(view);
}
_deregisterView(value, view: SwitchView): void {