summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2015-11-26 10:34:37 -0500
committerTavian Barnes <tavianator@tavianator.com>2015-11-26 10:34:37 -0500
commit4a24ca7003759f245a84754748f4e21f381bbb3d (patch)
treeba39f991ff3fd0b9ea1e516ce417cb4cd62266ae
parentd0243a72d56326af2c5ff7b7b3823dbe57b3bd4c (diff)
downloadbfs-4a24ca7003759f245a84754748f4e21f381bbb3d.tar.xz
Don't call fstatat() unless actually necessary in fill_statbuf().
-rw-r--r--bfs.c8
1 files 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;
}