Remove duplicated lstat syscall

Removes a unnecessary `lstat` syscall by calling `.metadata()` only
once. This makes `--type executable` searches about 15% faster.
This commit is contained in:
sharkdp 2018-08-19 16:23:06 +02:00
parent 6fb5004b85
commit 641976cf7a

View file

@ -219,9 +219,10 @@ pub fn scan(path_vec: &[PathBuf], pattern: Arc<Regex>, config: Arc<FdOptions>) {
if (entry_type.is_file() && !file_types.files)
|| (entry_type.is_dir() && !file_types.directories)
|| (entry_type.is_symlink() && !file_types.symlinks)
|| (entry.metadata().is_ok()
&& !fshelper::is_executable(&entry.metadata().unwrap())
&& file_types.executables_only)
|| (file_types.executables_only && !entry
.metadata()
.map(|m| fshelper::is_executable(&m))
.unwrap_or(false))
{
return ignore::WalkState::Continue;
} else if !(entry_type.is_file()