From 464b057f42c63e6557cfd5f1e89205a9305c912b Mon Sep 17 00:00:00 2001 From: Jonas Nyrup Date: Sun, 7 Jun 2026 19:09:08 +0200 Subject: [PATCH] Simplify string concatenation --- src/System.Management.Automation/utils/StringUtil.cs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) 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); } }