From 50a2bab5cd52d26d4a3bc786885a2c270ed3b227 Mon Sep 17 00:00:00 2001 From: sharkdp Date: Sun, 19 Aug 2018 16:27:23 +0200 Subject: [PATCH] Use short-circuiting for `--type` searches Reverses the order of boolean checks for `--type` searches, making them about 10% to 50% faster(!). --- src/walk.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/walk.rs b/src/walk.rs index 2f5a144..fa35d68 100644 --- a/src/walk.rs +++ b/src/walk.rs @@ -216,9 +216,9 @@ pub fn scan(path_vec: &[PathBuf], pattern: Arc, config: Arc) { if let Some(ref file_types) = config.file_types { if let Some(ref entry_type) = entry.file_type() { - if (entry_type.is_file() && !file_types.files) - || (entry_type.is_dir() && !file_types.directories) - || (entry_type.is_symlink() && !file_types.symlinks) + if (!file_types.files && entry_type.is_file()) + || (!file_types.directories && entry_type.is_dir()) + || (!file_types.symlinks && entry_type.is_symlink()) || (file_types.executables_only && !entry .metadata() .map(|m| fshelper::is_executable(&m))