From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: locate-dominating-file calls `stat' too eagerly Date: Mon, 29 Sep 2008 10:06:54 -0400 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1222697243 17179 80.91.229.12 (29 Sep 2008 14:07:23 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 29 Sep 2008 14:07:23 +0000 (UTC) Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Sep 29 16:08:18 2008 connect(): Connection refused Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1KkJQ1-0006U2-JC for ged-emacs-devel@m.gmane.org; Mon, 29 Sep 2008 16:08:09 +0200 Original-Received: from localhost ([127.0.0.1]:37823 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KkJOy-0006uo-PG for ged-emacs-devel@m.gmane.org; Mon, 29 Sep 2008 10:07:04 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KkJOu-0006ue-OL for emacs-devel@gnu.org; Mon, 29 Sep 2008 10:07:00 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KkJOt-0006uJ-AJ for emacs-devel@gnu.org; Mon, 29 Sep 2008 10:07:00 -0400 Original-Received: from [199.232.76.173] (port=57597 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KkJOt-0006uG-53 for emacs-devel@gnu.org; Mon, 29 Sep 2008 10:06:59 -0400 Original-Received: from ironport2-out.pppoe.ca ([206.248.154.182]:49623 helo=ironport2-out.teksavvy.com) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KkJOq-0003J7-7e; Mon, 29 Sep 2008 10:06:56 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgUFAB5+4EjO+KDT/2dsb2JhbACBYrobgWeBBA X-IronPort-AV: E=Sophos;i="4.33,331,1220241600"; d="scan'208";a="27705747" Original-Received: from 206-248-160-211.dsl.teksavvy.com (HELO pastel.home) ([206.248.160.211]) by ironport2-out.teksavvy.com with ESMTP; 29 Sep 2008 10:06:54 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id 6D0D94B4DE; Mon, 29 Sep 2008 10:06:54 -0400 (EDT) In-Reply-To: (Eli Zaretskii's message of "Mon, 29 Sep 2008 14:54:50 +0300") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:104220 Archived-At: > 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