commit 381f1d12a0aa3590467cbae9eb8401e5b316fc91
Author: FRIGN <[email protected]>
Date:   Thu Mar 12 13:29:12 2015 +0100

    Only call recurse() when path points to a directory in du(1)
    
    This improves performance by ~30%.

diff --git a/du.c b/du.c
index 0c46629..ef62166 100644
--- a/du.c
+++ b/du.c
@@ -47,7 +47,8 @@ du(const char *path, int depth, void *total)
                return;
        }
 
-       recurse(path, du, depth, &subtotal);
+       if (S_ISDIR(st.st_mode))
+               recurse(path, du, depth, &subtotal);
        *((size_t *)total) += subtotal + nblks(st.st_blocks);
 
        if (!sflag && depth <= maxdepth && (S_ISDIR(st.st_mode) || aflag))

Reply via email to