Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

String interpolation of only strings should light-up with string.Concat(params ReadOnlySpan<string>) #74538

Copy link
Copy link
@stephentoub

Description

@stephentoub
Issue body actions

Currently string interpolation when all of the parts are strings prefers to lower to a string.Concat call when there's a string.Concat overload with the exact same number of string parameters. Beyond that, it falls back to using normal interpolation mechanisms. Now that in .NET 9 there's a string.Concat(params ReadOnlySpan<string>) overload, it'd be nice if string interpolation preferred to use that overload when it's available, when all the parts are strings, and when there isn't a better overload of string.Concat available. This statement is invalidated by the new params span overload, which can support passing in all of the strings without an allocation:

// 4. The string is composed of more than 4 components that are all strings themselves. We can turn this into a single
// call to string.Concat. We prefer the builder over this because the builder can use pooling to avoid new allocations, while this
// call will need to allocate a param array.

cc: @333fred

rampaa

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.