From 40bdac274f6f4a0ee98b73f75f0e9ee929faa1cc Mon Sep 17 00:00:00 2001 From: Lynne Date: Mon, 26 Apr 2021 22:32:43 +1000 Subject: [PATCH] minor cleanup --- clippy.sh | 2 +- src/main.rs | 4 ++-- src/parameters.rs | 8 +++++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/clippy.sh b/clippy.sh index 7543773..0197375 100755 --- a/clippy.sh +++ b/clippy.sh @@ -1,6 +1,6 @@ #!/bin/bash fd -e rs -x touch {} -cargo clippy --all-targets --all-features -- \ +cargo clippy --all-features -- \ -W clippy::nursery \ -W clippy::perf \ -W clippy::pedantic \ diff --git a/src/main.rs b/src/main.rs index d23642d..045319b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -27,8 +27,6 @@ use clap::Clap; use env_logger::Env; use log::{debug, error, info, trace, warn}; use once_cell::sync::OnceCell; -#[cfg(feature = "multi-threaded")] -use rayon::prelude::*; use walkdir::{DirEntry, WalkDir}; use crate::findings::Findings; @@ -256,6 +254,8 @@ fn scan_file(entry: &DirEntry) -> Result { fn scan_from_walkdir(entries: &[DirEntry]) -> Vec> { cfg_if! { if #[cfg(feature = "multi-threaded")] { + use rayon::prelude::*; + // rather than using a standard par_iter, split the entries into chunks of 32 first. // this allows each spawned thread to handle 32 files before before closing, rather than creating a new thread for // each file. this leads to a pretty substantial speedup that i'm pretty substantially happy about 0u0 diff --git a/src/parameters.rs b/src/parameters.rs index f4e1e83..77e0cb2 100644 --- a/src/parameters.rs +++ b/src/parameters.rs @@ -116,11 +116,14 @@ impl Parameters { } pub fn default_verbosity(&self) -> &'static str { + #![allow(clippy::missing_const_for_fn)] + // match was not permitted inside const functions until 1.46 + match self.verbose { 0 => "warn", 1 => "info", 2 => "debug", - 3 | _ => "trace", + _ => "trace", } } } @@ -159,7 +162,7 @@ impl ExtensionSet { Self::Audio.extensions(), Self::Videos.extensions(), ] - .concat(), + .concat(), Self::Documents => vec![ "pdf", "doc", "docx", "ppt", "pptx", "xls", "xlsx", "csv", "tsv", "odt", "ods", "odp", "oda", "rtf", "ps", "pages", "key", "numbers", @@ -175,4 +178,3 @@ impl ExtensionSet { } } } -