Use StringBuilderCache in PathInternal.NormalizeDirectorySeparators (… · dotnet/coreclr@9d159ec (original) (raw)

This repository was archived by the owner on Jan 23, 2023. It is now read-only.

File tree

1 file changed

lines changed

1 file changed

lines changed

Original file line number Diff line number Diff line change
@@ -375,7 +375,7 @@ internal static string NormalizeDirectorySeparators(string path)
375 375 if (normalized)
376 376 return path;
377 377
378 -StringBuilder builder = new StringBuilder(path.Length);
378 +StringBuilder builder = StringBuilderCache.Acquire(path.Length);
379 379
380 380 int start = 0;
381 381 if (IsDirectorySeparator(path[start]))
@@ -404,7 +404,7 @@ internal static string NormalizeDirectorySeparators(string path)
404 404 builder.Append(current);
405 405 }
406 406
407 -return builder.ToString();
407 +return StringBuilderCache.GetStringAndRelease(builder);
408 408 }
409 409
410 410 ///