From d0243a72d56326af2c5ff7b7b3823dbe57b3bd4c Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Sat, 26 Sep 2015 12:54:18 -0400 Subject: Optimize -maxdepth in -depth mode. --- bftw.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) (limited to 'bftw.c') diff --git a/bftw.c b/bftw.c index 0bc49e1..d489bc8 100644 --- a/bftw.c +++ b/bftw.c @@ -593,6 +593,7 @@ static void bftw_init_buffers(bftw_state *state, const struct dirent *de) { ftwbuf->nameoff = 0; ftwbuf->error = 0; ftwbuf->depth = 0; + ftwbuf->visit = (state->status == BFTW_GC ? BFTW_POST : BFTW_PRE); ftwbuf->statbuf = NULL; ftwbuf->at_fd = AT_FDCWD; ftwbuf->at_path = ftwbuf->path; @@ -618,13 +619,6 @@ static void bftw_init_buffers(bftw_state *state, const struct dirent *de) { ftwbuf->typeflag = BFTW_UNKNOWN; } - // In BFTW_DEPTH mode, defer the stat() call for directories - if ((state->flags & BFTW_DEPTH) - && ftwbuf->typeflag == BFTW_DIR - && state->status == BFTW_CHILD) { - return; - } - if ((state->flags & BFTW_STAT) || ftwbuf->typeflag == BFTW_UNKNOWN) { if (ftwbuf_stat(ftwbuf, &state->statbuf) != 0) { state->error = errno; @@ -645,13 +639,6 @@ static int bftw_handle_path(bftw_state *state) { return BFTW_FAIL; } - // In BFTW_DEPTH mode, defer handling directories - if (state->ftwbuf.typeflag == BFTW_DIR - && (state->flags & BFTW_DEPTH) - && state->status != BFTW_GC) { - return BFTW_CONTINUE; - } - bftw_action action = state->fn(&state->ftwbuf, state->ptr); switch (action) { case BFTW_CONTINUE: -- cgit v1.2.3