Rollup merge of #139026 - yotamofek:pr/abs-diff, r=compiler-errors
Use `abs_diff` where applicable Very small cleanup, dogfooding a [new clippy lint](https://github.com/rust-lang/rust-clippy/pull/14482) I'm trying to add
This commit is contained in:
commit
2465b62858
2 changed files with 2 additions and 6 deletions
|
@ -118,7 +118,7 @@ pub fn edit_distance_with_substrings(a: &str, b: &str, limit: usize) -> Option<u
|
|||
// Check one isn't less than half the length of the other. If this is true then there is a
|
||||
// big difference in length.
|
||||
let big_len_diff = (n * 2) < m || (m * 2) < n;
|
||||
let len_diff = if n < m { m - n } else { n - m };
|
||||
let len_diff = m.abs_diff(n);
|
||||
let distance = edit_distance(a, b, limit + len_diff)?;
|
||||
|
||||
// This is the crux, subtracting length difference means exact substring matches will now be 0
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue