Skip to content

Commit 8814b6a

Browse files
committed
Optimize replace with one-length spans
1 parent dac463b commit 8814b6a

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/LinkDotNet.StringBuilder/ValueStringBuilder.Replace.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,12 @@ public void Replace(scoped ReadOnlySpan<char> oldValue, scoped ReadOnlySpan<char
9191
return;
9292
}
9393

94+
if (oldValue.Length == 1 && newValue.Length == 1)
95+
{
96+
Replace(oldValue[0], newValue[0], startIndex, count);
97+
return;
98+
}
99+
94100
var index = startIndex;
95101
var remainingChars = count;
96102

0 commit comments

Comments
 (0)