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.
This commit is contained in:
Xymist 2022-08-26 16:40:12 +01:00
parent d95d65c6a3
commit de41712291

View file

@ -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<String>) -> Vec<Match> {
score: matcher.score(candidate.as_str()),
content: candidate,
})
.filter(|m| m.score > 25)
.filter(|m| m.score > options.minimum_score)
.collect::<Vec<Match>>();
matches.par_sort_unstable_by(|a, b| a.score.cmp(&b.score));
matches