Page MenuHomePhorge

No OneTemporary

diff --git a/rust/sorter.rs b/rust/sorter.rs
index 71d2efa..3cce282 100644
--- a/rust/sorter.rs
+++ b/rust/sorter.rs
@@ -1,36 +1,36 @@
use super::matcher;
use rayon::prelude::*;
pub struct Match {
pub score: i64,
pub content: String,
}
pub struct Options {
pub pattern: String,
pub minimun_score: i64,
}
impl Options {
pub fn new(pattern: String) -> Self {
Self {
pattern,
minimun_score: 20,
}
}
}
pub fn sort_strings(options: Options, strings: Vec<String>) -> Vec<Match> {
let matcher = matcher::Matcher::new(options.pattern);
let mut matches = strings
.into_par_iter()
.map(|candidate| Match {
score: matcher.score(candidate.as_str()),
content: candidate,
})
.filter(|m| m.score > 25)
.collect::<Vec<Match>>();
- matches.sort_by(|a, b| a.score.cmp(&b.score));
+ matches.par_sort_unstable_by(|a, b| a.score.cmp(&b.score));
matches
}

File Metadata

Mime Type
text/x-diff
Expires
Sat, May 9, 3:13 AM (1 w, 1 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
9050
Default Alt Text
(1020 B)

Event Timeline