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:
@ -17,14 +17,14 @@ export class AbstractChangeDetector extends ChangeDetector {
|
||||
}
|
||||
|
||||
addChild(cd: ChangeDetector): void {
|
||||
ListWrapper.push(this.lightDomChildren, cd);
|
||||
this.lightDomChildren.push(cd);
|
||||
cd.parent = this;
|
||||
}
|
||||
|
||||
removeChild(cd: ChangeDetector): void { ListWrapper.remove(this.lightDomChildren, cd); }
|
||||
|
||||
addShadowDomChild(cd: ChangeDetector): void {
|
||||
ListWrapper.push(this.shadowDomChildren, cd);
|
||||
this.shadowDomChildren.push(cd);
|
||||
cd.parent = this;
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@ import {RecordType, ProtoRecord} from './proto_record';
|
||||
* replaced with very cheap SELF records.
|
||||
*/
|
||||
export function coalesce(records: List<ProtoRecord>): List<ProtoRecord> {
|
||||
var res: List<ProtoRecord> = ListWrapper.create();
|
||||
var res: List<ProtoRecord> = [];
|
||||
var indexMap: Map<number, number> = MapWrapper.create();
|
||||
|
||||
for (var i = 0; i < records.length; ++i) {
|
||||
@ -22,14 +22,14 @@ export function coalesce(records: List<ProtoRecord>): List<ProtoRecord> {
|
||||
var matchingRecord = _findMatching(record, res);
|
||||
|
||||
if (isPresent(matchingRecord) && record.lastInBinding) {
|
||||
ListWrapper.push(res, _selfRecord(record, matchingRecord.selfIndex, res.length + 1));
|
||||
res.push(_selfRecord(record, matchingRecord.selfIndex, res.length + 1));
|
||||
MapWrapper.set(indexMap, r.selfIndex, matchingRecord.selfIndex);
|
||||
|
||||
} else if (isPresent(matchingRecord) && !record.lastInBinding) {
|
||||
MapWrapper.set(indexMap, r.selfIndex, matchingRecord.selfIndex);
|
||||
|
||||
} else {
|
||||
ListWrapper.push(res, record);
|
||||
res.push(record);
|
||||
MapWrapper.set(indexMap, r.selfIndex, record.selfIndex);
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ enum TokenType {
|
||||
var tokens = [];
|
||||
var token = scanner.scanToken();
|
||||
while (token != null) {
|
||||
ListWrapper.push(tokens, token);
|
||||
tokens.push(token);
|
||||
token = scanner.scanToken();
|
||||
}
|
||||
return tokens;
|
||||
|
@ -99,11 +99,11 @@ export class Parser {
|
||||
var part = parts[i];
|
||||
if (i % 2 === 0) {
|
||||
// fixed string
|
||||
ListWrapper.push(strings, part);
|
||||
strings.push(part);
|
||||
} else {
|
||||
var tokens = this._lexer.tokenize(part);
|
||||
var ast = new _ParseAST(input, location, tokens, this._reflector, false).parseChain();
|
||||
ListWrapper.push(expressions, ast);
|
||||
expressions.push(ast);
|
||||
}
|
||||
}
|
||||
return new ASTWithSource(new Interpolation(strings, expressions), input, location);
|
||||
@ -194,7 +194,7 @@ class _ParseAST {
|
||||
var exprs = [];
|
||||
while (this.index < this.tokens.length) {
|
||||
var expr = this.parsePipe();
|
||||
ListWrapper.push(exprs, expr);
|
||||
exprs.push(expr);
|
||||
|
||||
if (this.optionalCharacter($SEMICOLON)) {
|
||||
if (!this.parseAction) {
|
||||
@ -222,7 +222,7 @@ class _ParseAST {
|
||||
var name = this.expectIdentifierOrKeyword();
|
||||
var args = [];
|
||||
while (this.optionalCharacter($COLON)) {
|
||||
ListWrapper.push(args, this.parsePipe());
|
||||
args.push(this.parsePipe());
|
||||
}
|
||||
result = new Pipe(result, name, args, true);
|
||||
} while (this.optionalOperator("|"));
|
||||
@ -456,7 +456,7 @@ class _ParseAST {
|
||||
var result = [];
|
||||
if (!this.next.isCharacter(terminator)) {
|
||||
do {
|
||||
ListWrapper.push(result, this.parsePipe());
|
||||
result.push(this.parsePipe());
|
||||
} while (this.optionalCharacter($COMMA));
|
||||
}
|
||||
return result;
|
||||
@ -469,9 +469,9 @@ class _ParseAST {
|
||||
if (!this.optionalCharacter($RBRACE)) {
|
||||
do {
|
||||
var key = this.expectIdentifierOrKeywordOrString();
|
||||
ListWrapper.push(keys, key);
|
||||
keys.push(key);
|
||||
this.expectCharacter($COLON);
|
||||
ListWrapper.push(values, this.parsePipe());
|
||||
values.push(this.parsePipe());
|
||||
} while (this.optionalCharacter($COMMA));
|
||||
this.expectCharacter($RBRACE);
|
||||
}
|
||||
@ -500,7 +500,7 @@ class _ParseAST {
|
||||
if (this.next.isCharacter($RPAREN)) return [];
|
||||
var positionals = [];
|
||||
do {
|
||||
ListWrapper.push(positionals, this.parsePipe());
|
||||
positionals.push(this.parsePipe());
|
||||
} while (this.optionalCharacter($COMMA));
|
||||
return positionals;
|
||||
}
|
||||
@ -522,7 +522,7 @@ class _ParseAST {
|
||||
var exprs = [];
|
||||
while (this.index < this.tokens.length && !this.next.isCharacter($RBRACE)) {
|
||||
var expr = this.parseExpression();
|
||||
ListWrapper.push(exprs, expr);
|
||||
exprs.push(expr);
|
||||
|
||||
if (this.optionalCharacter($SEMICOLON)) {
|
||||
while (this.optionalCharacter($SEMICOLON)) {
|
||||
@ -581,7 +581,7 @@ class _ParseAST {
|
||||
var source = this.input.substring(start, this.inputIndex);
|
||||
expression = new ASTWithSource(ast, source, this.location);
|
||||
}
|
||||
ListWrapper.push(bindings, new TemplateBinding(key, keyIsVar, name, expression));
|
||||
bindings.push(new TemplateBinding(key, keyIsVar, name, expression));
|
||||
if (!this.optionalCharacter($SEMICOLON)) {
|
||||
this.optionalCharacter($COMMA);
|
||||
}
|
||||
|
@ -448,26 +448,26 @@ export class IterableChanges extends Pipe {
|
||||
|
||||
var list = [];
|
||||
for (record = this._itHead; record !== null; record = record._next) {
|
||||
ListWrapper.push(list, record);
|
||||
list.push(record);
|
||||
}
|
||||
|
||||
var previous = [];
|
||||
for (record = this._previousItHead; record !== null; record = record._nextPrevious) {
|
||||
ListWrapper.push(previous, record);
|
||||
previous.push(record);
|
||||
}
|
||||
|
||||
var additions = [];
|
||||
for (record = this._additionsHead; record !== null; record = record._nextAdded) {
|
||||
ListWrapper.push(additions, record);
|
||||
additions.push(record);
|
||||
}
|
||||
var moves = [];
|
||||
for (record = this._movesHead; record !== null; record = record._nextMoved) {
|
||||
ListWrapper.push(moves, record);
|
||||
moves.push(record);
|
||||
}
|
||||
|
||||
var removals = [];
|
||||
for (record = this._removalsHead; record !== null; record = record._nextRemoved) {
|
||||
ListWrapper.push(removals, record);
|
||||
removals.push(record);
|
||||
}
|
||||
|
||||
return "collection: " + list.join(', ') + "\n" + "previous: " + previous.join(', ') + "\n" +
|
||||
|
@ -299,19 +299,19 @@ export class KeyValueChanges extends Pipe {
|
||||
var record: KVChangeRecord;
|
||||
|
||||
for (record = this._mapHead; record !== null; record = record._next) {
|
||||
ListWrapper.push(items, stringify(record));
|
||||
items.push(stringify(record));
|
||||
}
|
||||
for (record = this._previousMapHead; record !== null; record = record._nextPrevious) {
|
||||
ListWrapper.push(previous, stringify(record));
|
||||
previous.push(stringify(record));
|
||||
}
|
||||
for (record = this._changesHead; record !== null; record = record._nextChanged) {
|
||||
ListWrapper.push(changes, stringify(record));
|
||||
changes.push(stringify(record));
|
||||
}
|
||||
for (record = this._additionsHead; record !== null; record = record._nextAdded) {
|
||||
ListWrapper.push(additions, stringify(record));
|
||||
additions.push(stringify(record));
|
||||
}
|
||||
for (record = this._removalsHead; record !== null; record = record._nextRemoved) {
|
||||
ListWrapper.push(removals, stringify(record));
|
||||
removals.push(stringify(record));
|
||||
}
|
||||
|
||||
return "map: " + items.join(', ') + "\n" + "previous: " + previous.join(', ') + "\n" +
|
||||
|
@ -82,10 +82,9 @@ export class ProtoRecordBuilder {
|
||||
|
||||
_appendRecords(b: BindingRecord, variableNames: List<string>) {
|
||||
if (b.isDirectiveLifecycle()) {
|
||||
ListWrapper.push(
|
||||
this.records,
|
||||
new ProtoRecord(RecordType.DIRECTIVE_LIFECYCLE, b.lifecycleEvent, null, [], [], -1, null,
|
||||
this.records.length + 1, b, null, false, false));
|
||||
this.records.push(new ProtoRecord(RecordType.DIRECTIVE_LIFECYCLE, b.lifecycleEvent, null, [],
|
||||
[], -1, null, this.records.length + 1, b, null, false,
|
||||
false));
|
||||
} else {
|
||||
_ConvertAstIntoProtoRecords.append(this.records, b, variableNames);
|
||||
}
|
||||
@ -215,13 +214,13 @@ class _ConvertAstIntoProtoRecords implements AstVisitor {
|
||||
_addRecord(type, name, funcOrValue, args, fixedArgs, context) {
|
||||
var selfIndex = this._records.length + 1;
|
||||
if (context instanceof DirectiveIndex) {
|
||||
ListWrapper.push(this._records, new ProtoRecord(type, name, funcOrValue, args, fixedArgs, -1,
|
||||
context, selfIndex, this._bindingRecord,
|
||||
this._expressionAsString, false, false));
|
||||
this._records.push(new ProtoRecord(type, name, funcOrValue, args, fixedArgs, -1, context,
|
||||
selfIndex, this._bindingRecord, this._expressionAsString,
|
||||
false, false));
|
||||
} else {
|
||||
ListWrapper.push(this._records, new ProtoRecord(type, name, funcOrValue, args, fixedArgs,
|
||||
context, null, selfIndex, this._bindingRecord,
|
||||
this._expressionAsString, false, false));
|
||||
this._records.push(new ProtoRecord(type, name, funcOrValue, args, fixedArgs, context, null,
|
||||
selfIndex, this._bindingRecord, this._expressionAsString,
|
||||
false, false));
|
||||
}
|
||||
return selfIndex;
|
||||
}
|
||||
|
Reference in New Issue
Block a user