@@ -492,29 +492,29 @@ fn normalize_str_to_redactions(input: &str, pattern: &str, redactions: &Redactio
492
492
let mut input_index = 0 ;
493
493
let input_lines: Vec < _ > = crate :: utils:: LinesWithTerminator :: new ( input) . collect ( ) ;
494
494
let mut pattern_lines = crate :: utils:: LinesWithTerminator :: new ( pattern) . peekable ( ) ;
495
- ' outer : while let Some ( pattern_line) = pattern_lines. next ( ) {
495
+ while let Some ( pattern_line) = pattern_lines. next ( ) {
496
496
if is_line_elide ( pattern_line) {
497
497
let Some ( next_pattern_line) = pattern_lines. peek ( ) else {
498
- // Give up doing further normalization
498
+ // Stop as elide consumes to end
499
499
normalized. push ( pattern_line) ;
500
- // captured rest so don't copy remaining lines over
501
500
input_index = input_lines. len ( ) ;
502
501
break ;
503
502
} ;
504
- for ( index_offset, next_input_line) in
505
- input_lines[ input_index..] . iter ( ) . copied ( ) . enumerate ( )
506
- {
507
- if line_matches ( next_input_line, next_pattern_line, redactions) {
508
- normalized. push ( pattern_line) ;
509
- input_index += index_offset;
510
- continue ' outer;
511
- }
512
- }
513
- // Give up doing further normalization
514
- break ;
503
+ let Some ( index_offset) =
504
+ input_lines[ input_index..]
505
+ . iter ( )
506
+ . position ( |next_input_line| {
507
+ line_matches ( next_input_line, next_pattern_line, redactions)
508
+ } )
509
+ else {
510
+ // Give up as we can't find where the elide ends
511
+ break ;
512
+ } ;
513
+ normalized. push ( pattern_line) ;
514
+ input_index += index_offset;
515
515
} else {
516
516
let Some ( input_line) = input_lines. get ( input_index) else {
517
- // Give up doing further normalization
517
+ // Give up as we have no more content to check
518
518
break ;
519
519
} ;
520
520
0 commit comments