Commit 68a5704
committed
minor #57609 [TwigBridge] Use constant var name to cache
This PR was merged into the 7.2 branch.
Discussion
----------
[TwigBridge] Use constant var name to cache `trans_default_domain` expression result
| Q | A
| ------------- | ---
| Branch? | 7.2
| Bug fix? | no
| New feature? | no
| Deprecations? | no
| Issues | Part of #57588
| License | MIT
When `trans_default_domain` is used with an expression, the result of the expression is cached into a variable and this variable is stored in the `Scope` to be used for each following usage of the `|trans` filter.
This var name doesn't need to be random:
- there is only 1 value in the scope, more than 1 variable at a time is never necessary.
- if `trans_default_domain` is called a second time, the same variable can be reassigned.
The only benefit of using a random var name would be to prevent usage in the template. The name `__internal_trans_default_domain` self-explains that it is not meant to be used.
Commits
-------
ab116bb Use constant var name to cache trans_default_domain expression resulttrans_default_domain expression result (GromNaN)File tree
1 file changed
+4
-8
lines changed- src/Symfony/Bridge/Twig/NodeVisitor
1 file changed
+4
-8
lines changedLines changed: 4 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
| 34 | + | |
33 | 35 | | |
34 | 36 | | |
35 | 37 | | |
| |||
49 | 51 | | |
50 | 52 | | |
51 | 53 | | |
52 | | - | |
53 | | - | |
54 | | - | |
| 54 | + | |
| 55 | + | |
55 | 56 | | |
56 | 57 | | |
57 | 58 | | |
| |||
111 | 112 | | |
112 | 113 | | |
113 | 114 | | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | 115 | | |
0 commit comments