Skip to content

Commit 2e84ea2

Browse files
committed
Update CrossChunkMatcher.cs
1 parent 6b6bbb0 commit 2e84ea2

File tree

1 file changed

+8
-15
lines changed

1 file changed

+8
-15
lines changed

src/Verify/Serialization/Scrubbers/CrossChunkMatcher.cs

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,13 @@ public static void ReplaceAll<TContext>(
6161
}
6262

6363
// Apply matches in descending position order to maintain correct indices
64-
foreach (var match in matches.OrderByDescending(m => m.Index))
64+
foreach (var match in matches.OrderByDescending(_ => _.Index))
6565
{
6666
builder.Overwrite(match.Value, match.Index, match.Length);
6767
}
6868
}
6969

70-
static int FillBuffer(StringBuilder builder, int startPosition, Span<char> buffer)
70+
static int FillBuffer(StringBuilder builder, int start, Span<char> buffer)
7171
{
7272
var bufferIndex = 0;
7373
var currentPosition = 0;
@@ -78,17 +78,17 @@ static int FillBuffer(StringBuilder builder, int startPosition, Span<char> buffe
7878
var chunkEnd = currentPosition + chunk.Length;
7979

8080
// Skip chunks before our start position
81-
if (chunkEnd <= startPosition)
81+
if (chunkEnd <= start)
8282
{
8383
currentPosition = chunkEnd;
8484
continue;
8585
}
8686

8787
// Determine where to start in this chunk
88-
var chunkStartIndex = startPosition > currentPosition ? startPosition - currentPosition : 0;
88+
var chunkStart = start > currentPosition ? start - currentPosition : 0;
8989

9090
// Copy what we can from this chunk
91-
for (var i = chunkStartIndex; i < chunk.Length && bufferIndex < buffer.Length; i++)
91+
for (var i = chunkStart; i < chunk.Length && bufferIndex < buffer.Length; i++)
9292
{
9393
buffer[bufferIndex++] = chunkSpan[i];
9494
}
@@ -127,7 +127,7 @@ readonly struct MatchResult
127127
public readonly int MatchLength;
128128
public readonly string Replacement;
129129

130-
private MatchResult(bool isMatch, int matchLength, string replacement)
130+
MatchResult(bool isMatch, int matchLength, string replacement)
131131
{
132132
IsMatch = isMatch;
133133
MatchLength = matchLength;
@@ -137,15 +137,8 @@ private MatchResult(bool isMatch, int matchLength, string replacement)
137137
/// <summary>
138138
/// Creates a result indicating a match was found.
139139
/// </summary>
140-
public static MatchResult Match(int length, string replacement)
141-
{
142-
if (length <= 0)
143-
{
144-
throw new ArgumentException("Match length must be positive", nameof(length));
145-
}
146-
147-
return new(true, length, replacement);
148-
}
140+
public static MatchResult Match(int length, string replacement) =>
141+
new(true, length, replacement);
149142

150143
/// <summary>
151144
/// Creates a result indicating no match was found.

0 commit comments

Comments
 (0)