lower interpolated strings to string concatenation where possible#22595
lower interpolated strings to string concatenation where possible#22595KrisVandermotten wants to merge 7 commits intodotnet:masterfrom
Conversation
|
@dotnet-bot retest windows_release_vs-integration_prtest please |
| .maxstack 3 | ||
| .locals init (string V_0, //x | ||
| string V_1) //y | ||
| IL_0000: ldstr ""goodbye"" |
There was a problem hiding this comment.
This goodbye cannot be found in the concat version.
There was a problem hiding this comment.
Is has been optimized away, because it is not used (as it is overwritten by null later).
|
@gafter It seems that you wrote most of the original code. Would you like to take a look? |
|
I found a bug. The lowering is incorrect for There are three cases:
I will commit a fix as soon as possible. |
|
The bugs have been fixed. Given the following declarations: With |
|
@gafter Can you please review this PR? Any and all feedback would be most welcome. |
|
We apologize, but we are closing this PR due to code drift. We regret letting this PR go so long without attention, but at this point the code base has changed too much for us to revisit older PRs. Going forward, we will manage PRs better under an SLA currently under draft in issue #26266 – we encourage you to add comments to that draft as you see fit. Although that SLA is still in draft form, we nevertheless want to move forward with the identification of older PRs to give contributors as much early notice as possible to review and update them. If you are interested in pursuing this PR, please reset it against the head of master and we will reopen it. Thank you! |
This PR handles #22594.
Customer scenario
The user uses string interpolation where concatenation could be used.
Risk
This PR modifies code generation of interpolated strings, but only in the case where all fill-ins are strings without alignment or format specifiers.
Performance impact
Code generation for interpolated strings will be somewhat slower. The generated code will be significantly faster in the case where all fill-ins in the interpolated string are strings, without alignment or format specifiers. In all other cases, the new implementation has one additional loop over the parts with no memory allocations in it, fairly simple logic and early exit as soon it is determined that the code gen optimization cannot be done.