From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Eli Zaretskii <eliz@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: locate-dominating-file calls `stat' too eagerly
Date: Mon, 29 Sep 2008 10:06:54 -0400 [thread overview]
Message-ID: <jwvprmnt5b7.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <u1vz3kvzp.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 29 Sep 2008 14:54:50 +0300")
> This fragment from locate-dominating-file:
> (while (and dir
> ;; As a heuristic, we stop looking up the hierarchy of
> ;; directories as soon as we find a directory belonging to
> ;; another user. This should save us from looking in
> ;; things like /net and /afs. This assumes that all the
> ;; files inside a project belong to the same user.
> (let ((prev-user user))
> (setq user (nth 2 (file-attributes dir)))
> (or (null prev-user) (equal user prev-user))))
> (if (setq files (and (file-directory-p dir)
> (directory-files dir 'full regexp)))
> (throw 'found (car files))
> (if (equal dir
> (setq dir (file-name-directory
> (directory-file-name dir))))
> (setq dir nil))))
> repeatedly calls file-directory-p, even after file-directory-p already
> returned non-nil, which means that thereafter anything that
> file-name-directory returns will also necessarily be a directory.
> That looks like inefficiency, doesn't it? Here's the modification I
> propose:
Wouldn't it be simpler to wrap the `directroy-files' call inside
a condition-case and drop the file-directory-p altogether?
Stefan
next prev parent reply other threads:[~2008-09-29 14:06 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-29 11:54 locate-dominating-file calls `stat' too eagerly Eli Zaretskii
2008-09-29 14:06 ` Stefan Monnier [this message]
2008-09-29 14:36 ` Eli Zaretskii
2008-09-29 16:19 ` Stefan Monnier
2008-09-29 19:05 ` Eli Zaretskii
2008-09-29 20:45 ` Stefan Monnier
2008-09-30 7:14 ` Eli Zaretskii
2008-09-30 14:02 ` Stefan Monnier
2008-09-30 16:30 ` Eli Zaretskii
2008-09-30 12:52 ` Eli Zaretskii
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=jwvprmnt5b7.fsf-monnier+emacs@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.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.savannah.gnu.org/cgit/emacs.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).