Skip to content

Commit

Permalink
diff_sequences_kernel_bidirectional: remove step_by()
Browse files Browse the repository at this point in the history
  • Loading branch information
mookid committed Sep 5, 2023
1 parent 919425d commit 422048f
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/diffr_lib/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,8 @@ fn diff_sequences_kernel_bidirectional(
assert!(d < ctx_fwd.max);
assert!(d < ctx_bwd.max);
let d = to_isize(d);
for k in (-d..=d).step_by(2) {
let mut k = -d;
while k <= d {
let mut x = if k == -d || k != d && ctx_fwd.v(k - 1) < ctx_fwd.v(k + 1) {
ctx_fwd.v(k + 1)
} else {
Expand All @@ -454,8 +455,11 @@ fn diff_sequences_kernel_bidirectional(
return Some((Snake::default().from(x0, y0).len(x - x0), 2 * d - 1));
}
*ctx_fwd.v_mut(k) = x;

k += 2;
}
for k in (-d..=d).step_by(2) {
let mut k = -d;
while k <= d {
let mut x = if k == -d || k != d && ctx_bwd.v(k + 1) < ctx_bwd.v(k - 1) {
ctx_bwd.v(k + 1)
} else {
Expand All @@ -471,6 +475,8 @@ fn diff_sequences_kernel_bidirectional(
return Some((Snake::default().from(x, y).len(x1 - x), 2 * d));
}
*ctx_bwd.v_mut(k) = x - 1;

k += 2;
}
None
}
Expand Down

0 comments on commit 422048f

Please sign in to comment.