Optimization for string interpolation - simple scenarios: unfolding constants and lowering to concatenation
- Dominant language
- F#
- Stars
- 4.3k
- Forks
- 876
- Avg merge
- 4d 22h
- Merged PRs (30d)
- 144
Description
Seems like there is a lot we could do to improve perf of string interpolation. One good example is https://github.com/fsharp/fslang-suggestions/issues/1108, but also some low hanging fruits to start with could be unfolding compile time constants, e.g.:
```fsharp
[]
let x = "hello"
[]
let y = "world"
let z = $"{x} {y}!"
```
in the above, the last line could be lowered to `let z = "hello world!"`
Another one could be lowering to `System.String.Concat` when it applies, e.g. `let f (x: string) (y: string) = $"{x},{y}."` could be rewritten as `let f (x: string) (y: string) = System.String.Concat(x, ",", y, ".")`, because we know that all expression holes are filled with objects of type string and there are at most 4 pieces to concatenate.
Contributor guide
Assessment
This issue has not been assessed yet.