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

This improves performance by ~30%.
This commit is contained in:
FRIGN 2015-03-12 13:29:12 +01:00
parent af61ba738c
commit 3b187f4826
1 changed files with 2 additions and 1 deletions

3
du.c
View File

@ -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))