Skip to content

Commit ed28962

Browse files
perf: remove unnecessary manual string.Replace code. (#4134)
1 parent c530084 commit ed28962

File tree

1 file changed

+0
-20
lines changed

1 file changed

+0
-20
lines changed

TUnit.Core/Helpers/ArgumentFormatter.cs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -90,27 +90,7 @@ private static string FormatDefault(object? o)
9090
if (o is string str)
9191
{
9292
// Replace dots with middle dot (·) to prevent VS Test Explorer from interpreting them as namespace separators
93-
// Only do this if the string contains dots, to avoid unnecessary allocations
94-
if (!str.Contains('.'))
95-
{
96-
return str;
97-
}
98-
99-
#if NET8_0_OR_GREATER
100-
// Use Span<char> for better performance - avoid string.Replace allocation
101-
Span<char> buffer = str.Length <= 256
102-
? stackalloc char[str.Length]
103-
: new char[str.Length];
104-
105-
for (int i = 0; i < str.Length; i++)
106-
{
107-
buffer[i] = str[i] == '.' ? '·' : str[i];
108-
}
109-
110-
return new string(buffer);
111-
#else
11293
return str.Replace(".", "·");
113-
#endif
11494
}
11595

11696
if (toString == type.FullName || toString == type.AssemblyQualifiedName)

0 commit comments

Comments
 (0)