Skip to content

Commit 0bae2db

Browse files
CA1846: Performance: Prefer 'AsSpan' over 'Substring'
1 parent abc038c commit 0bae2db

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/NUnitConsole/nunit4-console/Options/Options.cs

+5-1
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,11 @@ private static IEnumerable<string> CreateWrappedLinesIterator(string self, IEnum
228228
--end;
229229
continuation = "-";
230230
}
231+
#if NETFRAMEWORK
231232
string line = self.Substring(start, end - start) + continuation;
233+
#else
234+
string line = string.Concat(self.AsSpan(start, end - start), continuation);
235+
#endif
232236
yield return line;
233237
start = end;
234238
if (char.IsWhiteSpace(c))
@@ -1544,7 +1548,7 @@ private static string GetDescription(string? description)
15441548
}
15451549
else
15461550
{
1547-
sb.Append(description.Substring(start, i - start));
1551+
sb.Append(description, start, i - start);
15481552
start = -1;
15491553
}
15501554
break;

0 commit comments

Comments
 (0)