Skip to content

Commit

Permalink
osa optimisation rapidfuzz#6
Browse files Browse the repository at this point in the history
use vec! for `curr_distances` construction, as with jaro optimisation rapidfuzz#3
  • Loading branch information
jnqnfe committed Nov 4, 2018
1 parent 960ff55 commit 56a2286
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,15 +283,14 @@ pub fn osa_distance(a: &str, b: &str) -> usize {

let mut prev_two_distances: Vec<usize> = Vec::with_capacity(b_numchars + 1);
let mut prev_distances: Vec<usize> = Vec::with_capacity(b_numchars + 1);
let mut curr_distances: Vec<usize> = Vec::with_capacity(b_numchars + 1);
let mut curr_distances: Vec<usize> = vec![0; b_numchars + 1];

let mut prev_a_char = char::MAX;
let mut prev_b_char = char::MAX;

for i in 0..=b_numchars {
prev_two_distances.push(i);
prev_distances.push(i);
curr_distances.push(0);
}

for (i, a_char) in a.chars().enumerate() {
Expand Down

0 comments on commit 56a2286

Please sign in to comment.