-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Add/use internal String.Concat overloads for spans #21766
Conversation
|
@dotnet-bot test Ubuntu x64 Checked Innerloop Build and Test please |
|
Is this important enough method to add extra more complex code to avoid the allocations? The Range/Index fix was close to my threashold, but I think this one is below it. |
It may not be. I can close if you don't think it's worth it. I'd searched msbuild to see its usage (https://github.com/Microsoft/msbuild/search?p=1&q=ChangeExtension&unscoped_q=ChangeExtension) and some of those seemed like they might be meaningful, but no smoking gun. (Also http://index/?leftProject=mscorlib&leftSymbol=vf50vlj9fsry&file=system%5Cio%5Cpath.cs for folks with access.) |
|
This change would look fine to me if it used I think |
I was thinking the same thing. Will do. |
In the common case where it need to replace a non-empty extension with a non-empty extension, it currently incurs a substring without the original extension prior to then concatenating with the new extension. This PR avoids that. (As the Path implementation is in corelib, this uses string.FastAllocateString and then formats into it with a span; if we wanted to avoid that, string.Create could also be used.)
8974208 to
41fb9fb
Compare
|
I added String.Concat overloads for spans, utilized them in a few places in corelib (including in Path.ChangeExtension), and opened https://github.com/dotnet/corefx/issues/34330 to make the methods public. |
|
@dotnet-bot test Windows_NT x64 Release CoreFX Tests please |
In the common case where it need to replace a non-empty extension with a non-empty extension, it currently incurs a substring without the original extension prior to then concatenating with the new extension. This PR avoids that. (As the Path implementation is in corelib, this uses string.FastAllocateString and then formats into it with a span; if we wanted to avoid that, string.Create could also be used.) * Add internal String.Concat overloads for spans * Use span-based string.Concat overloads in several places Signed-off-by: dotnet-bot <[email protected]>
In the common case where it need to replace a non-empty extension with a non-empty extension, it currently incurs a substring without the original extension prior to then concatenating with the new extension. This PR avoids that. (As the Path implementation is in corelib, this uses string.FastAllocateString and then formats into it with a span; if we wanted to avoid that, string.Create could also be used.) * Add internal String.Concat overloads for spans * Use span-based string.Concat overloads in several places Signed-off-by: dotnet-bot <[email protected]>
In the common case where it need to replace a non-empty extension with a non-empty extension, it currently incurs a substring without the original extension prior to then concatenating with the new extension. This PR avoids that. (As the Path implementation is in corelib, this uses string.FastAllocateString and then formats into it with a span; if we wanted to avoid that, string.Create could also be used.) * Add internal String.Concat overloads for spans * Use span-based string.Concat overloads in several places Signed-off-by: dotnet-bot <[email protected]>
In the common case where it need to replace a non-empty extension with a non-empty extension, it currently incurs a substring without the original extension prior to then concatenating with the new extension. This PR avoids that. (As the Path implementation is in corelib, this uses string.FastAllocateString and then formats into it with a span; if we wanted to avoid that, string.Create could also be used.) * Add internal String.Concat overloads for spans * Use span-based string.Concat overloads in several places Signed-off-by: dotnet-bot <[email protected]>
In the common case where it need to replace a non-empty extension with a non-empty extension, it currently incurs a substring without the original extension prior to then concatenating with the new extension. This PR avoids that. (As the Path implementation is in corelib, this uses string.FastAllocateString and then formats into it with a span; if we wanted to avoid that, string.Create could also be used.) * Add internal String.Concat overloads for spans * Use span-based string.Concat overloads in several places Signed-off-by: dotnet-bot <[email protected]>
In the common case where it need to replace a non-empty extension with a non-empty extension, it currently incurs a substring without the original extension prior to then concatenating with the new extension. This PR avoids that. (As the Path implementation is in corelib, this uses string.FastAllocateString and then formats into it with a span; if we wanted to avoid that, string.Create could also be used.) * Add internal String.Concat overloads for spans * Use span-based string.Concat overloads in several places Signed-off-by: dotnet-bot <[email protected]>
In the common case where it need to replace a non-empty extension with a non-empty extension, it currently incurs a substring without the original extension prior to then concatenating with the new extension. This PR avoids that. (As the Path implementation is in corelib, this uses string.FastAllocateString and then formats into it with a span; if we wanted to avoid that, string.Create could also be used.) * Add internal String.Concat overloads for spans * Use span-based string.Concat overloads in several places Signed-off-by: dotnet-bot <[email protected]>
In the common case where it need to replace a non-empty extension with a non-empty extension, it currently incurs a substring without the original extension prior to then concatenating with the new extension. This PR avoids that. (As the Path implementation is in corelib, this uses string.FastAllocateString and then formats into it with a span; if we wanted to avoid that, string.Create could also be used.) * Add internal String.Concat overloads for spans * Use span-based string.Concat overloads in several places Commit migrated from dotnet/coreclr@8f91ac8
In the common case where it need to replace a non-empty extension with a non-empty extension, it currently incurs a substring without the original extension prior to then concatenating with the new extension. This PR avoids that.
(As the
Pathimplementation is in corelib, this usesstring.FastAllocateStringand then formats into it with a span; if we wanted to avoid that,string.Createcould also be used. That could also be addressed with newString.Concatoverloads that acceptReadOnlySpan<char>s.)Benchmark:
Before:
After:
cc: @JeremyKuhne, @jkotas