Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH] Use access instead of stat in hashdir
- X-seq: zsh-workers 30182
- From: Raghavendra D Prabhu <raghu.prabhu13@xxxxxxxxx>
- To: Zsh workers <zsh-workers@xxxxxxx>
- Subject: [PATCH] Use access instead of stat in hashdir
- Date: Mon, 6 Feb 2012 18:43:02 +0530
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=date:from:to:subject:message-id:mail-followup-to:mime-version :content-type:content-disposition:x-operating-system:x-editor :user-agent; bh=FbiELGs5wPoVy4dZ+p2EJYT70kREbTljHVCX1V//eAU=; b=f/JKMou9uSuiWKc8a8SZXsyYdAhg9clffx/xSTFFR1ndEvhpbSf6fpXjEYskxq1XyO iP/kEzLQzDED5qrY3HnUbN2+C4Qs8Mq9FtDhF1N6bAAO0lA3SP2XoHJm9+ou8qIkslYB 7lbsqG7M0c78FpN/m4F4ZajyWJv1sMd760hyo=
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mail-followup-to: Zsh workers <zsh-workers@xxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
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