Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently string interpolation rely on 2 mechanisms:
String.+(_)
aka string concatenation.List
of string and performList.join()
on it.First patch optimize string concatenation, by taking advantage of string immutability. So adding an empty string can trivially optimized by returning the other value.
It is quite important since the compiler insert them when parsing interpolation strings values happen at the begin ("%(a)..."), in the middle ("...%(a)%(b)...") or at the end ("...%(a)").
The second patch eliminates spurious empty literal string concatenation, and the need of the helper
List
object. It is obsolete the first patch but it is remains an interesting change to have I think.Second patch technically produce a little bit more code, but I think in general case interpolated values have a lot of spurious empty strings that are eliminated, reducing code size to a similar size. In addition the removal of the helper
List
shows it has a significant impact in the benchmark.