emacs-devel
[Top][All Lists]
Advanced

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

Re: init_buffer PWD fix


From: Paul Eggert
Subject: Re: init_buffer PWD fix
Date: Tue, 23 Apr 2002 10:45:12 -0700 (PDT)

> From: MIYASHITA Hisashi <address@hidden>
> Date: Tue, 23 Apr 2002 15:14:31 +0900
> 
> But, in the first place, is this code necessary on all platform?

It's not necessary everywhere, but it's necessary on many platforms
(including GNU/Linux) and would be painful to figure out exactly which
platforms need it and which don't.

> Even now, is it really efficient on almost all of the platforms?

It's pretty efficent on POSIX or near-POSIX platforms, yes.  I suppose
it might be slow on Windows, though I'm not a Windows expert.

> FYI, I've tested the following code on Debian GNU/Linux (sid) to check
> the efficiency.

Efficiency is not the primary concern here.  More important are:

1) Correctness.  The current code works if a parent directory is
   searchable but not readable; on many hosts, getcwd won't work in
   that situation.

2) Using nice names for the working directory in the presence of
   symbolic links.  For example, on my host:

     15-shade $ cd /reb
     16-shade $ echo $PWD
     /reb
     17-shade $ /bin/pwd
     /net/sic/export/ford/reb

   When Emacs starts up, I want the working directory to be "/reb", not
   "/net/sic/export/ford/reb".

Your benchmark indicates that Emacs needs to spend one microsecond to
get the nicer name on your host; that's a win in my book.

> Therefore, I'd like to propose to remove this hacked optimization
> from init_buffer().

I'd rather leave it in, for the above reasons.  However, the code's
comment was misleading since it implies that the $PWD code is there
purely for optimization purposes.  It is faster on many traditional
hosts (for example, it is faster on my Solaris 8 host) but you're
correct that it's not faster on GNU/Linux hosts.

I have checked in a fix to the comment, so that it looks like this
instead:

  /* If PWD is accurate, use it instead of calling getwd.  PWD is
     sometimes a nicer name, and using it may avoid a fatal error if a
     parent directory is searchable but not readable.  */



reply via email to

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