Use ValueStringBuilder instead of StringBuilderCache in PathInternal.Windows.cs
authorStephen Toub <stoub@microsoft.com>
Thu, 3 Jan 2019 16:34:52 +0000 (11:34 -0500)
committerJan Kotas <jkotas@microsoft.com>
Fri, 4 Jan 2019 08:14:40 +0000 (22:14 -1000)
Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
src/System.Private.CoreLib/shared/System/IO/PathInternal.Windows.cs

index ef6c131..5e9e613 100644 (file)
@@ -375,7 +375,8 @@ namespace System.IO
             if (normalized)
                 return path;
 
-            StringBuilder builder = StringBuilderCache.Acquire(path.Length);
+            Span<char> initialBuffer = stackalloc char[MaxShortPath];
+            ValueStringBuilder builder = new ValueStringBuilder(initialBuffer);
 
             int start = 0;
             if (IsDirectorySeparator(path[start]))
@@ -404,7 +405,7 @@ namespace System.IO
                 builder.Append(current);
             }
 
-            return StringBuilderCache.GetStringAndRelease(builder);
+            return builder.ToString();
         }
 
         /// <summary>