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:
@ -76,7 +76,7 @@ function parsePathString(route: string) {
|
||||
}
|
||||
|
||||
var segments = splitBySlash(route);
|
||||
var results = ListWrapper.create();
|
||||
var results = [];
|
||||
var specificity = 0;
|
||||
|
||||
// The "specificity" of a path is used to determine which route is used when multiple routes match
|
||||
@ -97,12 +97,12 @@ function parsePathString(route: string) {
|
||||
var segment = segments[i], match;
|
||||
|
||||
if (isPresent(match = RegExpWrapper.firstMatch(paramMatcher, segment))) {
|
||||
ListWrapper.push(results, new DynamicSegment(match[1]));
|
||||
results.push(new DynamicSegment(match[1]));
|
||||
specificity += (100 - i);
|
||||
} else if (isPresent(match = RegExpWrapper.firstMatch(wildcardMatcher, segment))) {
|
||||
ListWrapper.push(results, new StarSegment(match[1]));
|
||||
results.push(new StarSegment(match[1]));
|
||||
} else if (segment.length > 0) {
|
||||
ListWrapper.push(results, new StaticSegment(segment));
|
||||
results.push(new StaticSegment(segment));
|
||||
specificity += 100 * (100 - i);
|
||||
}
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ export class RouteRecognizer {
|
||||
*
|
||||
*/
|
||||
recognize(url: string): List<RouteMatch> {
|
||||
var solutions = ListWrapper.create();
|
||||
var solutions = [];
|
||||
|
||||
MapWrapper.forEach(this.redirects, (target, path) => {
|
||||
// "/" redirect case
|
||||
@ -77,13 +77,13 @@ export class RouteRecognizer {
|
||||
matchedUrl = match[0];
|
||||
unmatchedUrl = StringWrapper.substring(url, match[0].length);
|
||||
}
|
||||
ListWrapper.push(solutions, new RouteMatch({
|
||||
specificity: pathRecognizer.specificity,
|
||||
handler: pathRecognizer.handler,
|
||||
params: pathRecognizer.parseParams(url),
|
||||
matchedUrl: matchedUrl,
|
||||
unmatchedUrl: unmatchedUrl
|
||||
}));
|
||||
solutions.push(new RouteMatch({
|
||||
specificity: pathRecognizer.specificity,
|
||||
handler: pathRecognizer.handler,
|
||||
params: pathRecognizer.parseParams(url),
|
||||
matchedUrl: matchedUrl,
|
||||
unmatchedUrl: unmatchedUrl
|
||||
}));
|
||||
}
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user