File tree Expand file tree Collapse file tree 1 file changed +16
-12
lines changed
src/Verify/Serialization/Scrubbers Expand file tree Collapse file tree 1 file changed +16
-12
lines changed Original file line number Diff line number Diff line change @@ -38,19 +38,23 @@ public static void ReplaceAll<TContext>(
3838 var windowSlice = buffer [ ..bufferLength ] ;
3939 var result = matcher ( windowSlice , absolutePosition , context ) ;
4040
41- if ( result . IsMatch )
41+ if ( ! result . IsMatch )
4242 {
43- matches . Add ( new Match ( absolutePosition , result . MatchLength , result . Replacement ) ) ;
44-
45- // Skip past the match
46- var skipAmount = result . MatchLength - 1 ;
47- if ( skipAmount > 0 )
48- {
49- var remaining = chunk . Length - chunkIndex - 1 ;
50- var toSkip = Math . Min ( skipAmount , remaining ) ;
51- chunkIndex += toSkip ;
52- }
43+ continue ;
5344 }
45+
46+ matches . Add ( new ( absolutePosition , result . MatchLength , result . Replacement ) ) ;
47+
48+ // Skip past the match
49+ var skipAmount = result . MatchLength - 1 ;
50+ if ( skipAmount <= 0 )
51+ {
52+ continue ;
53+ }
54+
55+ var remaining = chunk . Length - chunkIndex - 1 ;
56+ var toSkip = Math . Min ( skipAmount , remaining ) ;
57+ chunkIndex += toSkip ;
5458 }
5559
5660 position += chunk . Length ;
@@ -140,7 +144,7 @@ public static MatchResult Match(int length, string replacement)
140144 throw new ArgumentException ( "Match length must be positive" , nameof ( length ) ) ;
141145 }
142146
143- return new MatchResult ( true , length , replacement ) ;
147+ return new ( true , length , replacement ) ;
144148 }
145149
146150 /// <summary>
You can’t perform that action at this time.
0 commit comments