emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: locate-dominating-file calls `stat' too eagerly


From: Stefan Monnier
Subject: Re: locate-dominating-file calls `stat' too eagerly
Date: Mon, 29 Sep 2008 10:06:54 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)

> 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]