use div_ceil instead of manual logic

This commit is contained in:
Folkert de Vries
2025-07-05 08:36:27 +02:00
parent 226b0fbe11
commit ed3711ea29
12 changed files with 17 additions and 18 deletions

View File

@@ -130,7 +130,7 @@ pub fn edit_distance_with_substrings(a: &str, b: &str, limit: usize) -> Option<u
1 // Exact substring match, but not a total word match so return non-zero
} else if !big_len_diff {
// Not a big difference in length, discount cost of length difference
score + (len_diff + 1) / 2
score + len_diff.div_ceil(2)
} else {
// A big difference in length, add back the difference in length to the score
score + len_diff