refactor(ListWrapper): drop filter, find, reduce & any

Closes #5152
This commit is contained in:
Victor Berchet
2015-10-09 09:07:58 -07:00
parent e667ad3e6b
commit 0dcca1a28e
30 changed files with 66 additions and 98 deletions

View File

@ -120,9 +120,8 @@ function _mayBeAddRecord(record: ProtoRecord, dstRecords: ProtoRecord[], exclude
*/
function _findFirstMatch(record: ProtoRecord, dstRecords: ProtoRecord[],
excludedIdxs: number[]): ProtoRecord {
return ListWrapper.find(
dstRecords,
// TODO(vicb): optimize notReusableIndexes.indexOf (sorted array)
return dstRecords.find(
// TODO(vicb): optimize excludedIdxs.indexOf (sorted array)
rr => excludedIdxs.indexOf(rr.selfIndex) == -1 && rr.mode !== RecordType.DirectiveLifecycle &&
_haveSameDirIndex(rr, record) && rr.mode === record.mode &&
looseIdentical(rr.funcOrValue, record.funcOrValue) &&

View File

@ -180,7 +180,7 @@ export class CodegenNameUtil {
* Generates statements destroying all pipe variables.
*/
genPipeOnDestroy(): string {
return ListWrapper.filter(this._records, (r) => { return r.isPipeRecord(); })
return this._records.filter(r => r.isPipeRecord())
.map(r => `${this._utilName}.callPipeOnDestroy(${this.getPipeName(r.selfIndex)});`)
.join('\n');
}

View File

@ -71,7 +71,7 @@ export class IterableDiffers {
}
find(iterable: Object): IterableDifferFactory {
var factory = ListWrapper.find(this.factories, f => f.supports(iterable));
var factory = this.factories.find(f => f.supports(iterable));
if (isPresent(factory)) {
return factory;
} else {

View File

@ -71,7 +71,7 @@ export class KeyValueDiffers {
}
find(kv: Object): KeyValueDifferFactory {
var factory = ListWrapper.find(this.factories, f => f.supports(kv));
var factory = this.factories.find(f => f.supports(kv));
if (isPresent(factory)) {
return factory;
} else {

View File

@ -101,8 +101,7 @@ export class DynamicChangeDetector extends AbstractChangeDetector<any> {
/** @internal */
_matchingEventBindings(eventName: string, elIndex: number): EventBinding[] {
return ListWrapper.filter(this._eventBindings,
eb => eb.eventName == eventName && eb.elIndex === elIndex);
return this._eventBindings.filter(eb => eb.eventName == eventName && eb.elIndex === elIndex);
}
hydrateDirectives(directives: any): void {