mirror of
https://github.com/rust-lang/cargo.git
synced 2025-10-01 11:30:39 +00:00
Auto merge of #9954 - gilescope:lev_tighten, r=ehuss
nit: Allocated slightly bigger vec than needed I think this is slightly more correct as the rest of the algorithm is focusing on chars not bytes, so this is more consistent.
This commit is contained in:
commit
a821e2cb24
@ -1,14 +1,15 @@
|
||||
use std::cmp;
|
||||
|
||||
pub fn lev_distance(me: &str, t: &str) -> usize {
|
||||
let t_len = t.chars().count();
|
||||
if me.is_empty() {
|
||||
return t.chars().count();
|
||||
return t_len;
|
||||
}
|
||||
if t.is_empty() {
|
||||
return me.chars().count();
|
||||
}
|
||||
|
||||
let mut dcol = (0..=t.len()).collect::<Vec<_>>();
|
||||
let mut dcol = (0..=t_len).collect::<Vec<_>>();
|
||||
let mut t_last = 0;
|
||||
|
||||
for (i, sc) in me.chars().enumerate() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user