>From a884f9d641f0749504acfd4e39a48c3fb7bd393e Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sat, 25 Apr 2020 11:02:53 -0700 Subject: [PATCH] Tune fts for FTS_LOGICAL+FTS_NOSTAT >From a suggestion by Askar Safin in: https://lists.gnu.org/r/bug-gnulib/2020-04/msg00074.html * lib/fts.c (fts_build): If file types are known, optimize FTS_LOGICAL+FTS_NOSTAT for non-symlinks and non-directories the same way that we already optimize FTS_PHYSICAL+FTS_NOSTAT for non-directories. --- ChangeLog | 10 ++++++++++ lib/fts.c | 7 ++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4bf912fe4..c13c82bac 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2020-04-25 Paul Eggert + + Tune fts for FTS_LOGICAL+FTS_NOSTAT + From a suggestion by Askar Safin in: + https://lists.gnu.org/r/bug-gnulib/2020-04/msg00074.html + * lib/fts.c (fts_build): If file types are known, optimize + FTS_LOGICAL+FTS_NOSTAT for non-symlinks and non-directories the + same way that we already optimize FTS_PHYSICAL+FTS_NOSTAT for + non-directories. + 2020-04-19 Bruno Haible vasnprintf: Add support for printing wide characters using escapes. diff --git a/lib/fts.c b/lib/fts.c index ade8c3349..bf62dfa92 100644 --- a/lib/fts.c +++ b/lib/fts.c @@ -1511,10 +1511,11 @@ mem1: saved_errno = errno; inode numbers. Some day we might optimize that away, too, for directories where d_ino is known to be valid. */ - bool skip_stat = (ISSET(FTS_PHYSICAL) - && ISSET(FTS_NOSTAT) + bool skip_stat = (ISSET(FTS_NOSTAT) && DT_IS_KNOWN(dp) - && ! DT_MUST_BE(dp, DT_DIR)); + && ! DT_MUST_BE(dp, DT_DIR) + && (ISSET(FTS_PHYSICAL) + || ! DT_MUST_BE(dp, DT_LNK))); p->fts_info = FTS_NSOK; /* Propagate dirent.d_type information back to caller, when possible. */ -- 2.25.3