From cae28a955824115ed0a1f3c925469286569fd1bc Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Fri, 12 Jun 2020 14:11:33 -0400 Subject: 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. --- bftw.c | 7 ++++--- 1 file 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) { -- cgit v1.2.3