From 4a24ca7003759f245a84754748f4e21f381bbb3d Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Thu, 26 Nov 2015 10:34:37 -0500 Subject: Don't call fstatat() unless actually necessary in fill_statbuf(). --- bfs.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bfs.c b/bfs.c index 7669e6d..a203468 100644 --- a/bfs.c +++ b/bfs.c @@ -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; } -- cgit v1.2.3