From e38f111a603e229bb5b346230c76840750a186c1 Mon Sep 17 00:00:00 2001 From: Leopold Luley Date: Mon, 4 Nov 2024 11:43:37 +0100 Subject: [PATCH] Use all available cores for search. Apparently, the `ignore` crate just defaults to 2. --- core/src/search.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/core/src/search.rs b/core/src/search.rs index 8a9fcef..a0b8514 100644 --- a/core/src/search.rs +++ b/core/src/search.rs @@ -64,12 +64,18 @@ pub fn run(engine: SearchEngine, params: SearchParameters) { } let matcher = matcher.unwrap(); + let threads = match std::thread::available_parallelism() { + Ok(cores) => cores.get(), + Err(_) => 2, + }; + let walker = WalkBuilder::new(¶ms.base_directory) .git_ignore(!params.flags.search_ignored) .ignore(!params.flags.search_ignored) .hidden(params.flags.search_hidden) .follow_links(params.flags.follow_links) .same_file_system(params.flags.same_filesystem) + .threads(threads) .build_parallel(); let mut preprocessors: Vec<(_, extra::ExtraFn)> = Vec::new();