diff --git a/Cargo.lock b/Cargo.lock index 11ab482..fd5d598 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -274,6 +274,7 @@ dependencies = [ "fuzzy-matcher", "ignore", "lazy_static", + "rayon", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 44b677a..75c6974 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,6 +12,7 @@ path = "rust/lib.rs" ignore = "0.4" fuzzy-matcher = "0.3.7" lazy_static = "1.4.0" +rayon = "1.5.3" [dev-dependencies] criterion = "0.3.6" diff --git a/rust/sorter.rs b/rust/sorter.rs index cc7c31b..71d2efa 100644 --- a/rust/sorter.rs +++ b/rust/sorter.rs @@ -1,8 +1,5 @@ use super::matcher; -use super::thread_pool; - -use std::sync::mpsc; -use std::sync::Arc; +use rayon::prelude::*; pub struct Match { pub score: i64, @@ -27,7 +24,7 @@ pub fn sort_strings(options: Options, strings: Vec) -> Vec { let matcher = matcher::Matcher::new(options.pattern); let mut matches = strings - .into_iter() + .into_par_iter() .map(|candidate| Match { score: matcher.score(candidate.as_str()), content: candidate,