Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

[PATCH] Use access instead of stat in hashdir



Hi,

I found that using access instead of two stat calls results in faster rehash when it is done. I came across this when I noticed too many stat calls while 'strace -c'
diff --git a/Src/hashtable.c b/Src/hashtable.c
index 775b6a2..43d2e2e 100644
--- a/Src/hashtable.c
+++ b/Src/hashtable.c
@@ -664,8 +664,7 @@ hashdir(char **dirp)
            * executable plain files.
            */
            if (unset(HASHEXECUTABLESONLY) ||
-                   (stat(pathbuf, &statbuf) == 0 &&
-                    S_ISREG(statbuf.st_mode) && (statbuf.st_mode & S_IXUGO)))
+                   !access(pathbuf,X_OK))
                add = 1;
        }
        if (add) {





Regards,
--
Raghavendra Prabhu
GPG Id : 0xD72BE977
Fingerprint: B93F EBCB 8E05 7039 CD3C A4B8 A616 DCA1 D72B E977
www: wnohang.net

Attachment: pgpb8qmKiQY1N.pgp
Description: PGP signature



Messages sorted by: Reverse Date, Date, Thread, Author