summaryrefslogtreecommitdiffstats
path: root/bftw.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2015-09-26 12:54:18 -0400
committerTavian Barnes <tavianator@tavianator.com>2015-09-26 12:54:18 -0400
commitd0243a72d56326af2c5ff7b7b3823dbe57b3bd4c (patch)
tree10a9f4223ca594252392b8bf46b80e031f9dbb86 /bftw.c
parent4bedd5a6f7b12e0923dd6fa180dcaad7e1f75fc2 (diff)
downloadbfs-d0243a72d56326af2c5ff7b7b3823dbe57b3bd4c.tar.xz
Optimize -maxdepth in -depth mode.
Diffstat (limited to 'bftw.c')
-rw-r--r--bftw.c15
1 files changed, 1 insertions, 14 deletions
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: