Skip to content
Myr

Use short-circuiting for `--type` searches

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Reverses the order of boolean checks for `--type` searches, making them about 10% to 50% faster(!).

authored by sharkdp · committed by sharkdp · parent 641976c · Browse files · 1 file+3 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+3 added−3 removed

  • other:+3 added−3 removed

1 file+3 added−3 removed

modified:src/walk.rs+3 added-3 removed
214 unmodified lines
215 // Filter out unwanted file types.216217 if let Some(ref file_types) = config.file_types {218 if let Some(ref entry_type) = entry.file_type() {219 if (entry_type.is_file() && !file_types.files)220 || (entry_type.is_dir() && !file_types.directories)221 || (entry_type.is_symlink() && !file_types.symlinks)219 if (!file_types.files && entry_type.is_file())220 || (!file_types.directories && entry_type.is_dir())221 || (!file_types.symlinks && entry_type.is_symlink())222 || (file_types.executables_only && !entry223 .metadata()224 .map(|m| fshelper::is_executable(&m))225 .unwrap_or(false))
78 unmodified lines