Skip to content

Commit

Permalink
perf(router): don't create new serializer every time UrlTree.toString…
Browse files Browse the repository at this point in the history
… is called (#15565)
  • Loading branch information
Dzmitry Shylovich authored and vicb committed Mar 29, 2017
1 parent c828511 commit fd61145
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/router/src/url_tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,15 @@ export class UrlTree {
/** The fragment of the URL */
public fragment: string) {}

get queryParamMap() {
get queryParamMap(): ParamMap {
if (!this._queryParamMap) {
this._queryParamMap = convertToParamMap(this.queryParams);
}
return this._queryParamMap;
}

/** @docsNotRequired */
toString(): string { return new DefaultUrlSerializer().serialize(this); }
toString(): string { return DEFAULT_SERIALIZER.serialize(this); }
}

/**
Expand Down Expand Up @@ -294,6 +294,8 @@ export class DefaultUrlSerializer implements UrlSerializer {
}
}

const DEFAULT_SERIALIZER = new DefaultUrlSerializer();

export function serializePaths(segment: UrlSegmentGroup): string {
return segment.segments.map(p => serializePath(p)).join('/');
}
Expand Down

0 comments on commit fd61145

Please sign in to comment.