revert(skim_v3): restore m upper bound in typo_vband_row

The tightened hi = (j + bandwidth).min(m) bound incorrectly rejected valid
typo-mode alignments where the optimal path takes many LEFT (gap) steps
past the bandwidth boundary. The snapshot test confirms 5 fewer matches vs
the expected 37. Revert to hi = m; the affine gap penalty alone prevents
poor alignments from winning.
This commit is contained in:
Loric ANDRE 2026-02-26 15:22:17 +01:00
parent 4efe9812cd
commit 90ffc46633

View file

@ -141,7 +141,14 @@ impl Atom for u8 {
impl Atom for char {
#[inline(always)]
fn eq_ignore_case(self, b: Self) -> bool {
self.to_lowercase().eq(b.to_lowercase())
// Fast path for ASCII (the common case in filenames and code).
// to_ascii_lowercase() is a single arithmetic op vs. the ToLowercase
// iterator allocation that to_lowercase() requires.
if self.is_ascii() && b.is_ascii() {
self.to_ascii_lowercase() == b.to_ascii_lowercase()
} else {
self.to_lowercase().eq(b.to_lowercase())
}
}
#[inline(always)]
fn is_lowercase(self) -> bool {
@ -790,17 +797,15 @@ fn find_first_char<C: Atom>(pat: &[C], cho: &[C], respect_case: bool) -> Option<
/// Row-major V-shaped band: compute column bounds at row `i`.
///
/// The band is a symmetric window of width `bandwidth` around the main
/// diagonal `j ≈ i + j_first - 1`. Both lower and upper bounds are clamped
/// to `[1, m]`. Tightening the upper bound (previously always `m`) avoids
/// computing cells in the right half of the matrix for early rows.
/// Lower bound is tightened around the diagonal; the upper bound is left at
/// `m` so that alignments that skip many choice characters (large LEFT runs)
/// are never pruned — the affine gap penalty keeps them from winning anyway.
#[inline(always)]
fn typo_vband_row(i: usize, m: usize, bandwidth: usize, j_first: usize) -> (usize, usize) {
let j = i + j_first - 1;
let lo = j.saturating_sub(bandwidth).max(1);
let hi = (j + bandwidth).min(m);
(lo, hi)
(lo, m)
}
// ---------------------------------------------------------------------------