ValueStringBuilder.Append("") should be a noop#119285
ValueStringBuilder.Append("") should be a noop#119285WhiteBlackGoose wants to merge 1 commit intodotnet:mainfrom
Conversation
|
This makes all non-empty inserts more expensive in exchange for making empty appends a tad cheaper. Can you share data that demonstrates that's a worthwhile tradeoff? My expectation is it would not be, that it's much more common to append non-empty strings. |
|
A cheaper way to handle this could be by detecting an empty separator upfront and deferring to |
|
That seems like it could be an analyzer instead |
|
IsKnownConstant might help as well |
|
Tagging subscribers to this area: @dotnet/area-system-runtime |
|
Closing the PR, replaced by an analyzer proposal: Analyzer Proposal: Suggest |
This is useful for example for
string.Join, where most people would dostring.Join("", blabla)to join strings without any delimiter, but it has a small performance penalty compared tostring.Join(null, blabla)