Skip to content

Commit 2f00a15

Browse files
committed
Fix poor performance when using --long
Previously, the unix extended attributes are always read no matter what. This is not ideal, as it is very expensive to call for files which we will not display and leads to significantly (~80x with level = 2) worse runtimes recursing large directories. This is fixed by only calling `unix::Attrs::from` when it is a file which is going to be displayed.
1 parent 393baea commit 2f00a15

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/tree/node/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,9 @@ impl TryFrom<(DirEntry, &Context)> for Node {
272272
let inode = Inode::try_from(&metadata).ok();
273273

274274
#[cfg(unix)]
275-
let unix_attrs = if ctx.long {
275+
let unix_attrs = if ctx.long
276+
&& path.components().count() <= ctx.dir_canonical().components().count().saturating_add(ctx.level())
277+
{
276278
unix::Attrs::from((&metadata, &dir_entry))
277279
} else {
278280
unix::Attrs::default()

0 commit comments

Comments
 (0)