[hackers] [sbase] Only call recurse() when path points to a directory in du(1) || FRIGN

From: <git_AT_suckless.org>
Date: Fri, 13 Mar 2015 12:41:20 +0100 (CET)

commit 381f1d12a0aa3590467cbae9eb8401e5b316fc91
Author: FRIGN <dev_AT_frign.de>
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
_AT_@ -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))
Received on Fri Mar 13 2015 - 12:41:20 CET

This archive was generated by hypermail 2.3.0 : Fri Mar 13 2015 - 12:48:10 CET