On 4/25/20 1:29 AM, Bernhard Voelker wrote:
> despite many people are bored due to Corona lock-down in many
> countries, for me it's rather the opposite.

Oh yes, things are pretty busy around here too. It's been predicted that over
half of all working-age Americans will not be drawing wages next month, but the
minority who are still working have more to do than ever. And although I'm too
old to be a "working-age American", I'm still one of the worker bees.

That being said, Askar's idea looks good to me, though the code can be simpler
than what he proposed. I installed the attached patch into Gnulib. Thanks, 
Askar.
>From a884f9d641f0749504acfd4e39a48c3fb7bd393e Mon Sep 17 00:00:00 2001
From: Paul Eggert <egg...@cs.ucla.edu>
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  <egg...@cs.ucla.edu>
+
+	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  <br...@clisp.org>
 
 	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

Reply via email to