Remove `ValueStringBuilder.Concat`?
Just wondering if this could be removed, since string.Concat seems to do pretty much the same thing, except for the fact that it might box value types.
Just wondering if this could be removed, since
string.Concatseems to do pretty much the same thing, except for the fact that it might box value types.
Yes exactly - and that is the only reason those functions exist. I wanted to create a small set of helper methods where people can easil just append a few things without mich overhead.
Maybe no one uses them :) that might be true. Then we could remove them in a new major version
If they are being kept, you should replace Concat<T>(params T[]) with Concat<T>(params ReadOnlySpan<T>) to avoid allocations :)
If they are being kept, you should replace
Concat<T>(params T[])withConcat<T>(params ReadOnlySpan<T>)to avoid allocations :)
Good point - we could also use params Span<T>. The upcoming C# version may have some special handling where arrays would be automatically cast to Span if appropriate.
I will flag this as v3
If they are being kept, you should replace
Concat<T>(params T[])withConcat<T>(params ReadOnlySpan<T>)to avoid allocations :)Good point - we could also use
params Span<T>. The upcoming C# version may have some special handling where arrays would be automatically cast toSpanif appropriate. I will flag this asv3
Hi @linkdotnet, arrays are already implicitly cast to ReadOnlySpan and Span.
char[] array = new char[4];
ReadOnlySpan<char> span = array;
I'm not sure what you're referring to by:
The upcoming C# version may have some special handling where arrays would be automatically cast to
Spanif appropriate.
If they are being kept, you should replace
Concat<T>(params T[])withConcat<T>(params ReadOnlySpan<T>)to avoid allocations :)Good point - we could also use
params Span<T>. The upcoming C# version may have some special handling where arrays would be automatically cast toSpanif appropriate. I will flag this asv3Hi @linkdotnet, arrays are already implicitly cast to
ReadOnlySpanandSpan.char[] array = new char[4]; ReadOnlySpan
span = array; I'm not sure what you're referring to by: The upcoming C# version may have some special handling where arrays would be automatically cast to
Spanif appropriate.
Sorry, should have put in the link: https://github.com/dotnet/csharplang/issues/7905
Hey @Joy-less
I made a recent change (which will be v3 as there are smaller breaking changes) that will use params ReadOnlySpan<T>. Therefore thanks for the suggestion and I will close that ticket.