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:
parent
d95d65c6a3
commit
de41712291
1 changed files with 3 additions and 3 deletions
|
|
@ -8,14 +8,14 @@ pub struct Match {
|
||||||
|
|
||||||
pub struct Options {
|
pub struct Options {
|
||||||
pub pattern: String,
|
pub pattern: String,
|
||||||
pub minimun_score: i64,
|
pub minimum_score: i64,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Options {
|
impl Options {
|
||||||
pub fn new(pattern: String) -> Self {
|
pub fn new(pattern: String) -> Self {
|
||||||
Self {
|
Self {
|
||||||
pattern,
|
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()),
|
score: matcher.score(candidate.as_str()),
|
||||||
content: candidate,
|
content: candidate,
|
||||||
})
|
})
|
||||||
.filter(|m| m.score > 25)
|
.filter(|m| m.score > options.minimum_score)
|
||||||
.collect::<Vec<Match>>();
|
.collect::<Vec<Match>>();
|
||||||
matches.par_sort_unstable_by(|a, b| a.score.cmp(&b.score));
|
matches.par_sort_unstable_by(|a, b| a.score.cmp(&b.score));
|
||||||
matches
|
matches
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue