Optimise hunk search within matched_lines

This reduces instructions from 29B instructions to 22B for the sample
file in #153.
pull/166/head
Wilfred Hughes 2022-03-12 14:40:49 +07:00
parent dad463daf5
commit 9439a932e6
1 changed files with 2 additions and 1 deletions

@ -664,9 +664,10 @@ pub fn matched_lines_for_hunk(
} }
let mut end_i = None; let mut end_i = None;
for (i, matched_line) in matched_lines.iter().enumerate() { for (i, matched_line) in matched_lines.iter().enumerate().rev() {
if either_side_equal(matched_line, hunk_last) { if either_side_equal(matched_line, hunk_last) {
end_i = Some(i + 1); end_i = Some(i + 1);
break;
} }
} }