Skip to content

Commit

Permalink
Remove duplicated lstat syscall
Browse files Browse the repository at this point in the history
Removes a unnecessary `lstat` syscall by calling `.metadata()` only
once. This makes `--type executable` searches about 15% faster.
  • Loading branch information
sharkdp committed Aug 19, 2018
1 parent 6fb5004 commit 641976c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/walk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 641976c

Please sign in to comment.