zsh-workers
 help / color / mirror / code / Atom feed
From: Raghavendra D Prabhu <raghu.prabhu13@gmail.com>
To: Zsh workers <zsh-workers@zsh.org>
Subject: [PATCH] Use access instead of stat in hashdir
Date: Mon, 6 Feb 2012 18:43:02 +0530	[thread overview]
Message-ID: <20120206131302.GA46184@Xye> (raw)

[-- 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 --]

             reply	other threads:[~2012-02-06 13:19 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-06 13:13 Raghavendra D Prabhu [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120206131302.GA46184@Xye \
    --to=raghu.prabhu13@gmail.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).