Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optimize allocations in TextReader.ReadToEnd utilized by SourceText.F…
…rom (#70017) * Optimize allocations in TextReader.ReadToEnd utilized by SourceText.From The profile I'm looking currently shows 9.4% of allocation in our codeanalysis process under SourceText.From. These allocations occur during the TextReader.ReadToEnd call. Fortunately, Roslyn is already passing in a TextReader that knows it's length, and thus we can optimize this path. In netfx, this should at least get rid of the extra sizing allocations done during TextReader.ReadToEnd as it appends to it's internal stringbuilder. So, this should see a reduction of about 20% of the allocations in this codepath. In netcore (which is the case for this profile), we do better as this essentially gets rid of all allocations except for the equivalent of the StringBuilder.ToString call. So, this should see a reduction of about 2/3 of the allocations of this codepath.
- Loading branch information