perf(router): don't create new serializer every time UrlTree.toString is called (#15565)
This commit is contained in:
parent
a580f8c61f
commit
0c36f2353d
|
@ -115,7 +115,7 @@ export class UrlTree {
|
||||||
/** The fragment of the URL */
|
/** The fragment of the URL */
|
||||||
public fragment: string) {}
|
public fragment: string) {}
|
||||||
|
|
||||||
get queryParamMap() {
|
get queryParamMap(): ParamMap {
|
||||||
if (!this._queryParamMap) {
|
if (!this._queryParamMap) {
|
||||||
this._queryParamMap = convertToParamMap(this.queryParams);
|
this._queryParamMap = convertToParamMap(this.queryParams);
|
||||||
}
|
}
|
||||||
|
@ -123,7 +123,7 @@ export class UrlTree {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @docsNotRequired */
|
/** @docsNotRequired */
|
||||||
toString(): string { return new DefaultUrlSerializer().serialize(this); }
|
toString(): string { return DEFAULT_SERIALIZER.serialize(this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -294,6 +294,8 @@ export class DefaultUrlSerializer implements UrlSerializer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const DEFAULT_SERIALIZER = new DefaultUrlSerializer();
|
||||||
|
|
||||||
export function serializePaths(segment: UrlSegmentGroup): string {
|
export function serializePaths(segment: UrlSegmentGroup): string {
|
||||||
return segment.segments.map(p => serializePath(p)).join('/');
|
return segment.segments.map(p => serializePath(p)).join('/');
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue