From de41712291f194d7ea82aec5601138fc0a1102a7 Mon Sep 17 00:00:00 2001 From: Xymist Date: Fri, 26 Aug 2022 16:40:12 +0100 Subject: [PATCH] Return to using `minimum_score` - Update the provided `minimum_score` in `sorter::Option::new` to match what was being used in `sort_strings` - Use the `minimum_score` value instead of a hardcoded number This seems like functionality that was either intended and not added, or added and then part removed. Either way the performance impact is minimal and it's a nice idea. --- rust/sorter.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rust/sorter.rs b/rust/sorter.rs index 3cce282..f81f622 100644 --- a/rust/sorter.rs +++ b/rust/sorter.rs @@ -8,14 +8,14 @@ pub struct Match { pub struct Options { pub pattern: String, - pub minimun_score: i64, + pub minimum_score: i64, } impl Options { pub fn new(pattern: String) -> Self { Self { pattern, - minimun_score: 20, + minimum_score: 25, } } } @@ -29,7 +29,7 @@ pub fn sort_strings(options: Options, strings: Vec) -> Vec { score: matcher.score(candidate.as_str()), content: candidate, }) - .filter(|m| m.score > 25) + .filter(|m| m.score > options.minimum_score) .collect::>(); matches.par_sort_unstable_by(|a, b| a.score.cmp(&b.score)); matches