diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2015-09-26 12:54:18 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2015-09-26 12:54:18 -0400 |
commit | d0243a72d56326af2c5ff7b7b3823dbe57b3bd4c (patch) | |
tree | 10a9f4223ca594252392b8bf46b80e031f9dbb86 /bfs.c | |
parent | 4bedd5a6f7b12e0923dd6fa180dcaad7e1f75fc2 (diff) | |
download | bfs-d0243a72d56326af2c5ff7b7b3823dbe57b3bd4c.tar.xz |
Optimize -maxdepth in -depth mode.
Diffstat (limited to 'bfs.c')
-rw-r--r-- | bfs.c | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -891,7 +891,17 @@ static bftw_action cmdline_callback(struct BFTW *ftwbuf, void *ptr) { state.action = BFTW_SKIP_SUBTREE; } - if (ftwbuf->depth >= cl->mindepth && ftwbuf->depth <= cl->maxdepth) { + // In -depth mode, only handle directories on the BFTW_POST visit + bftw_visit expected_visit = BFTW_PRE; + if ((cl->flags & BFTW_DEPTH) + && ftwbuf->typeflag == BFTW_DIR + && ftwbuf->depth < cl->maxdepth) { + expected_visit = BFTW_POST; + } + + if (ftwbuf->visit == expected_visit + && ftwbuf->depth >= cl->mindepth + && ftwbuf->depth <= cl->maxdepth) { cl->expr->eval(cl->expr, &state); } |