zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH] Use access instead of stat in hashdir
@ 2012-02-06 13:13 Raghavendra D Prabhu
  2012-02-06 16:20 ` Bart Schaefer
  0 siblings, 1 reply; 5+ messages in thread
From: Raghavendra D Prabhu @ 2012-02-06 13:13 UTC (permalink / raw)
  To: Zsh workers

[-- Attachment #1: Type: text/plain, Size: 839 bytes --]

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 #2: Type: application/pgp-signature, Size: 490 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-02-08  0:47 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-06 13:13 [PATCH] Use access instead of stat in hashdir Raghavendra D Prabhu
2012-02-06 16:20 ` Bart Schaefer
2012-02-06 16:52   ` Bart Schaefer
2012-02-07 22:46   ` Raghavendra D Prabhu
2012-02-08  0:40     ` Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).