Skip to content

Conversation

@teo-tsirpanis
Copy link
Contributor

@teo-tsirpanis teo-tsirpanis commented Nov 29, 2021

This PR converts all calls to StringBuilder.AppendFormat in non-test code to instead use StringBuilder.Append with interpolated strings, taking advantage of the .NET 6 interpolated string handlers, that allocate zero intermediate objects, writing the characters directly to the StringBuilder in our case.

Call sites where the format strings were obtained from resources could not be optimized and were not changed.

Earlier frameworks might see a slightly decreased performance but the changed code does not seem to be performance-critical.

@ghost ghost added the community-contribution Indicates that the PR has been added by a community member label Nov 29, 2021
@ghost
Copy link

ghost commented Nov 29, 2021

I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label.

Copy link
Member

@stephentoub stephentoub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

Copy link
Contributor

@deeprobin deeprobin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job!

@marek-safar marek-safar merged commit 079245b into dotnet:main Jan 3, 2022
@teo-tsirpanis teo-tsirpanis deleted the appendformat-interpolated branch January 3, 2022 10:56
@ghost ghost locked as resolved and limited conversation to collaborators Feb 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants