Skip to content
Myr

Remove duplicated `lstat` syscall

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

Removes a unnecessary `lstat` syscall by calling `.metadata()` only once. This makes `--type executable` searches about 15% faster.

authored by sharkdp · committed by sharkdp · parent 6fb5004 · Browse files · 1 file+4 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+4 added−3 removed

  • other:+4 added−3 removed

1 file+4 added−3 removed

modified:src/walk.rs+4 added-3 removed
217 unmodified lines
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)222 || (entry.metadata().is_ok()223 && !fshelper::is_executable(&entry.metadata().unwrap())224 && file_types.executables_only)222 || (file_types.executables_only && !entry223 .metadata()224 .map(|m| fshelper::is_executable(&m))225 .unwrap_or(false))226 {227 return ignore::WalkState::Continue;228 } else if !(entry_type.is_file()229 || entry_type.is_dir()
74 unmodified lines