sbase

suckless unix tools
git clone git://git.2f30.org/sbase
Log | Files | Refs | README | LICENSE

commit 3b187f482653da01f59a9f37344d20ad7fcf3447
parent af61ba738cab2eaf72d9007dccc24398f32f2ddb
Author: FRIGN <dev@frign.de>
Date:   Thu, 12 Mar 2015 13:29:12 +0100

Only call recurse() when path points to a directory in du(1)

This improves performance by ~30%.

Diffstat:
Mdu.c | 3++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git 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))