diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2015-11-26 10:34:37 -0500 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2015-11-26 10:34:37 -0500 |
commit | 4a24ca7003759f245a84754748f4e21f381bbb3d (patch) | |
tree | ba39f991ff3fd0b9ea1e516ce417cb4cd62266ae | |
parent | d0243a72d56326af2c5ff7b7b3823dbe57b3bd4c (diff) | |
download | bfs-4a24ca7003759f245a84754748f4e21f381bbb3d.tar.xz |
Don't call fstatat() unless actually necessary in fill_statbuf().
-rw-r--r-- | bfs.c | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -52,6 +52,9 @@ typedef struct { */ static void fill_statbuf(eval_state *state) { struct BFTW *ftwbuf = state->ftwbuf; + if (ftwbuf->statbuf) { + return; + } if (fstatat(ftwbuf->at_fd, ftwbuf->at_path, &state->statbuf, AT_SYMLINK_NOFOLLOW) == 0) { ftwbuf->statbuf = &state->statbuf; @@ -357,10 +360,11 @@ static bool eval_name(const expression *expr, eval_state *state) { * -print action. */ static bool eval_print(const expression *expr, eval_state *state) { - if (state->cl->colors) { + color_table *colors = state->cl->colors; + if (colors) { fill_statbuf(state); } - pretty_print(state->cl->colors, state->ftwbuf); + pretty_print(colors, state->ftwbuf); return true; } |