summaryrefslogtreecommitdiffstats
path: root/bftw.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2020-06-12 14:11:33 -0400
committerTavian Barnes <tavianator@tavianator.com>2020-06-12 14:11:33 -0400
commitcae28a955824115ed0a1f3c925469286569fd1bc (patch)
tree3ba9061f3cd542c168ca92e0b6c3fc8b634bdd2d /bftw.c
parent30969de9bfe7d565e70eef6c23095741ffb9b285 (diff)
downloadbfs-cae28a955824115ed0a1f3c925469286569fd1bc.tar.xz
bftw: Only do another level of deepening if there are unexplored directories
This makes -S ids about 20% faster on a checkout of the Linux kernel.
Diffstat (limited to 'bftw.c')
-rw-r--r--bftw.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/bftw.c b/bftw.c
index 87f629b..ffd51f9 100644
--- a/bftw.c
+++ b/bftw.c
@@ -1528,13 +1528,14 @@ static enum bftw_action bftw_ids_callback(const struct BFTW *ftwbuf, void *ptr)
}
}
- state->bottom = false;
-
enum bftw_action ret = state->delegate(ftwbuf, state->ptr);
switch (ret) {
case BFTW_CONTINUE:
- ret = BFTW_PRUNE;
+ if (ftwbuf->typeflag == BFTW_DIR) {
+ state->bottom = false;
+ ret = BFTW_PRUNE;
+ }
break;
case BFTW_PRUNE:
if (ftwbuf->typeflag == BFTW_DIR) {