summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsharkdp <davidpeter@web.de>2018-11-04 20:21:19 +0100
committersharkdp <davidpeter@web.de>2018-11-04 20:21:19 +0100
commitb4c571d0341fdc5f523b134d23aed9915a3f29a4 (patch)
treec089154ada1d4c5f7424ed66f4f4d7159b882ace
parent37adb1466ff62d8a2feda835789adc673e6df1ac (diff)
Use symlink_metadata for a huge speedup
-rw-r--r--src/walk.rs7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/walk.rs b/src/walk.rs
index b80df07..9b660d7 100644
--- a/src/walk.rs
+++ b/src/walk.rs
@@ -14,7 +14,7 @@ type SizeEntry = (Option<UniqueID>, u64);
fn walk(tx: channel::Sender<SizeEntry>, entries: &[PathBuf]) {
entries.into_par_iter().for_each_with(tx, |tx_ref, entry| {
- if let Ok(metadata) = entry.metadata() {
+ if let Ok(metadata) = entry.symlink_metadata() {
// If the entry has more than one hard link, generate
// a unique ID consisting of device and inode in order
// not to count this entry twice.
@@ -32,15 +32,14 @@ fn walk(tx: channel::Sender<SizeEntry>, entries: &[PathBuf]) {
let mut children = vec![];
for child_entry in fs::read_dir(entry).unwrap() {
if let Ok(child_entry) = child_entry {
- let path = child_entry.path();
- children.push(PathBuf::from(path));
+ children.push(child_entry.path());
}
}
walk(tx_ref.clone(), &children[..]);
};
} else {
- eprintln!("Could not get metadata: '{}'", entry.to_string_lossy());
+ eprintln!("Could not get file metadata: '{}'", entry.to_string_lossy());
};
});
}