diff --git a/rust/matcher.rs b/rust/matcher.rs index cbbf6d7..59a15b1 100644 --- a/rust/matcher.rs +++ b/rust/matcher.rs @@ -17,8 +17,7 @@ impl Matcher { pub fn score(&self, text: &str) -> i64 { self.matcher - .fuzzy_indices(text, &self.pattern) - .map(|(score, _indices)| score) + .fuzzy_match(text, &self.pattern) .unwrap_or_default() } } diff --git a/rust/sorter.rs b/rust/sorter.rs index f81f622..2778789 100644 --- a/rust/sorter.rs +++ b/rust/sorter.rs @@ -25,12 +25,19 @@ pub fn sort_strings(options: Options, strings: Vec) -> Vec { let mut matches = strings .into_par_iter() - .map(|candidate| Match { - score: matcher.score(candidate.as_str()), - content: candidate, + .filter_map(|candidate| { + let score = matcher.score(candidate.as_str()); + if score > options.minimum_score { + return None; + } + + Some(Match { + score, + content: candidate, + }) }) - .filter(|m| m.score > options.minimum_score) .collect::>(); + matches.par_sort_unstable_by(|a, b| a.score.cmp(&b.score)); matches }