Skip to content

perf(router): don't create new serializer every time UrlTree.toString is called #15565

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 28, 2017

Conversation

DzmitryShylovich
Copy link
Contributor

DefaultUrlSerializer is stateless so there's no need to create a new instance every time.

@@ -103,6 +103,7 @@ function containsSegmentGroupHelper(
* @stable
*/
export class UrlTree {
private serializer = new DefaultUrlSerializer();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

scope it to the file so that we don't have to create it for all new Tree ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea

@vicb vicb added area: router action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews labels Mar 28, 2017
@DzmitryShylovich
Copy link
Contributor Author

@vicb fixed

@@ -294,6 +294,8 @@ export class DefaultUrlSerializer implements UrlSerializer {
}
}

const serializer = new DefaultUrlSerializer();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move this up and change the name to DEFAULT_SERIALIZER pls

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, could you please only change the name then ?

@vicb vicb added action: merge The PR is ready for merge by the caretaker and removed action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews labels Mar 28, 2017
@vicb vicb merged commit 0c36f23 into angular:master Mar 28, 2017
@DzmitryShylovich DzmitryShylovich deleted the gh/urltree-perf branch March 28, 2017 23:22
vicb pushed a commit that referenced this pull request Mar 29, 2017
smurfy pushed a commit to smurfy/angular that referenced this pull request Apr 7, 2017
smurfy pushed a commit to smurfy/angular that referenced this pull request May 2, 2017
asnowwolf pushed a commit to asnowwolf/angular that referenced this pull request Aug 11, 2017
juleskremer pushed a commit to juleskremer/angular that referenced this pull request Aug 28, 2017
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker area: router cla: yes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants