Improve performance of Path.ChangeExtension (dotnet/coreclr#21766)
commit011610e4402b8bb25f4b6c1dc5c2ed21a4712fe6
authorStephen Toub <stoub@microsoft.com>
Thu, 3 Jan 2019 21:34:56 +0000 (3 16:34 -0500)
committerMarek Safar <marek.safar@gmail.com>
Fri, 4 Jan 2019 08:29:04 +0000 (4 09:29 +0100)
treeb8297d43b53c9a9bc781c64283f0564acf9d21fa
parentd3747f620bea4f9fb4d6fbb98e2aa0b6b2b79ce7
Improve performance of Path.ChangeExtension (dotnet/coreclr#21766)

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 <dotnet-bot@microsoft.com>
netcore/System.Private.CoreLib/shared/System/Globalization/CultureData.Unix.cs
netcore/System.Private.CoreLib/shared/System/Globalization/CultureData.cs
netcore/System.Private.CoreLib/shared/System/Globalization/DateTimeFormatInfo.cs
netcore/System.Private.CoreLib/shared/System/Globalization/DateTimeFormatInfoScanner.cs
netcore/System.Private.CoreLib/shared/System/IO/Path.cs
netcore/System.Private.CoreLib/shared/System/String.Manipulation.cs