Skip to content
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

refactor: consider reusing temporary vars in generated code #41491

Closed
AndrewKushnir opened this issue Apr 7, 2021 · 1 comment
Closed

refactor: consider reusing temporary vars in generated code #41491

AndrewKushnir opened this issue Apr 7, 2021 · 1 comment
Assignees
Labels
area: compiler Issues related to `ngc`, Angular's template compiler area: core Issues related to the framework runtime P4 A relatively minor issue that is not relevant to core functions refactoring Issue that involves refactoring or code-cleanup state: has PR
Milestone

Comments

@AndrewKushnir
Copy link
Contributor

PR #41437 introduced support for ?? operator in Angular expressions. In order to support that in emitted JS code, there are few temporary vars generated (see this discussion). This ticket is to capture that discussion and investigate if it's feasible to reuse temporary vars instead of generating new ones for each expression.

@AndrewKushnir AndrewKushnir added refactoring Issue that involves refactoring or code-cleanup area: core Issues related to the framework runtime area: compiler Issues related to `ngc`, Angular's template compiler P4 A relatively minor issue that is not relevant to core functions labels Apr 7, 2021
@ngbot ngbot bot modified the milestone: Backlog Apr 7, 2021
crisbeto added a commit to crisbeto/angular that referenced this issue Apr 11, 2021
… nullish coalescing

This is follow-up from angular#41437 and it reduces the amount of code we generate for safe property accesses (`a?.b`) and nullish coalescing (`a ?? b`) by:
1. Reusing variables in nested nullish coalescing expressions.
2. Not initializing temporary variables to `null`. The way our code is generated means that the value will always be overwritten before we compare against it so the initializer didn't really matter.

Fixes angular#41491.
crisbeto added a commit to crisbeto/angular that referenced this issue Apr 12, 2021
… nullish coalescing

This is follow-up from angular#41437 and it reduces the amount of code we generate for safe property accesses (`a?.b`) and nullish coalescing (`a ?? b`) by:
1. Reusing variables in nested nullish coalescing expressions.
2. Not initializing temporary variables to `null`. The way our code is generated means that the value will always be overwritten before we compare against it so the initializer didn't really matter.

Fixes angular#41491.
crisbeto added a commit to crisbeto/angular that referenced this issue Apr 13, 2021
… nullish coalescing

This is follow-up from angular#41437 and it reduces the amount of code we generate for safe property accesses (`a?.b`) and nullish coalescing (`a ?? b`) by:
1. Reusing variables in nested nullish coalescing expressions.
2. Not initializing temporary variables to `null`. The way our code is generated means that the value will always be overwritten before we compare against it so the initializer didn't really matter.

Fixes angular#41491.
@zarend zarend closed this as completed in dde81ba Apr 14, 2021
zarend pushed a commit that referenced this issue Apr 14, 2021
… nullish coalescing (#41563)

This is follow-up from #41437 and it reduces the amount of code we generate for safe property accesses (`a?.b`) and nullish coalescing (`a ?? b`) by:
1. Reusing variables in nested nullish coalescing expressions.
2. Not initializing temporary variables to `null`. The way our code is generated means that the value will always be overwritten before we compare against it so the initializer didn't really matter.

Fixes #41491.

PR Close #41563
@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 May 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: compiler Issues related to `ngc`, Angular's template compiler area: core Issues related to the framework runtime P4 A relatively minor issue that is not relevant to core functions refactoring Issue that involves refactoring or code-cleanup state: has PR
Projects
None yet
2 participants