bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#13539: Use fdopendir, fstatat and readlinkat, for efficiency.


From: Eli Zaretskii
Subject: bug#13539: Use fdopendir, fstatat and readlinkat, for efficiency.
Date: Mon, 28 Jan 2013 16:37:48 +0200

> Date: Mon, 28 Jan 2013 00:34:49 -0800
> From: Paul Eggert <eggert@cs.ucla.edu>
> CC: 13539@debbugs.gnu.org
> 
> > Is it really worth our while to spend energy on speeding up an API
> > that goes mostly unused in Emacs?  Its only heavy user is ls-lisp.el,
> 
> This patch also improves the performance of file-name-completion
> -- perhaps you missed that part?

I just didn't imagine that file-name-completion would need to call
'lstat'.  But now I see that it does, even twice in a row -- only so
it could support FOO/ in completion-ignored-extensions.  So perhaps a
further optimization would be to avoid the call to
file_name_completion_stat if completion-ignored-extensions is devoid
of elements that end in a slash.

> Better than that, w32 can model the POSIX file descriptor by
> using an int that represents the directory name.

Yes, this is indeed much simpler, thanks.  I have only one comment:

> +static DIR *
> +open_directory (char const *name, int *fdp)
> +{
> +  DIR *d;
> +  int fd, opendir_errno;
> +
> +  block_input ();
> +
> +#ifdef DOS_NT
> +  /* Directories cannot be opened, so emulate an open directory with
> +     its name, cast to a pointer.  This is good enough for Emacs.  */
> +  fd = (int) name;
          ^^^^^
I think we should use ptrdiff_t rather than int here, since that could
make a difference in 64-bit builds on Windows.





reply via email to

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