Idea: Investigate if interpolated string handler for incremental generators can improve perf
- Dominant language
- C#
- Stars
- 20.7k
- Forks
- 4.3k
- PR merge metrics
- PR metrics pending
Description
I don't have any data or any specific source gen in mind. Just idea came to mind and thought it might be interesting to consider, if it wasn't previously.
Some source generators might be producing a big chunk of string as the last step, but just as a single big interpolated string (not needing StringBuilder, etc).
As what the compiler cares about at the end is having `SourceText` instance, I wonder if it could be possible to not construct the full string at all by having some internal `SourceText` implementation that is more smart and gets constructed via interpolated string handler.
`SourceText` mostly needs these APIs AFAIK:
```
int Length { get; }
void CopyTo(int sourceIndex, char[] destination, int destinationIndex, int count)
string ToString(TextSpan span)
```
I think these might be possible to implement without constructing the full string. Whether or not this will make any notable impact isn't something I know. I think this needs some numbers and experimentations.
Contributor guide
Assessment
This issue has not been assessed yet.