diff --git a/src/System.Management.Automation/utils/StringUtil.cs b/src/System.Management.Automation/utils/StringUtil.cs index 8daf31866df..98cf1081711 100644 --- a/src/System.Management.Automation/utils/StringUtil.cs +++ b/src/System.Management.Automation/utils/StringUtil.cs @@ -243,11 +243,7 @@ internal static string VtSubstring(this string str, int startOffset, int length, } else { - int capacity = length + prependStr?.Length ?? 0 + appendStr?.Length ?? 0; - return new StringBuilder(prependStr, capacity) - .Append(str, startOffset, length) - .Append(appendStr) - .ToString(); + return string.Concat(prependStr, str.AsSpan(startOffset, length), appendStr); } }