diff options
| author | Paul Eggert | 2017-07-31 12:31:02 -0700 |
|---|---|---|
| committer | Paul Eggert | 2017-07-31 12:56:51 -0700 |
| commit | 3a8d0cc825635e07da2a90c4ac987b476fc9b05d (patch) | |
| tree | 7a18ef1a777007f05feff6a35ebadc4338330906 /m4 | |
| parent | 192342a3a93a2e467ab589ae2d1ffd5e7acf1398 (diff) | |
| download | emacs-3a8d0cc825635e07da2a90c4ac987b476fc9b05d.tar.gz emacs-3a8d0cc825635e07da2a90c4ac987b476fc9b05d.zip | |
Avoid most stat calls when completing file names
* admin/merge-gnulib (GNULIB_MODULES): Add d-type.
* lib/gnulib.mk.in, m4/gnulib-comp.m4: Regenerate.
* m4/d-type.m4: New file, copied from gnulib.
* src/dired.c (DT_UNKNOWN, DT_DIR, DT_LINK)
[!HAVE_STRUCT_DIRENT_D_TYPE]: New constants.
(dirent_type): New function.
(file_name_completion): Use it, to avoid unnecessary calls to
stat-like functions on GNU/Linux and other platforms with d_type.
(file_name_completion_stat): Just follow the link; there is no
need to try first with AT_SYMLINK_NOFOLLOW since the directory
entry was already checked to exist.
Diffstat (limited to 'm4')
| -rw-r--r-- | m4/d-type.m4 | 32 | ||||
| -rw-r--r-- | m4/gnulib-comp.m4 | 3 |
2 files changed, 35 insertions, 0 deletions
diff --git a/m4/d-type.m4 b/m4/d-type.m4 new file mode 100644 index 00000000000..c819fc02f84 --- /dev/null +++ b/m4/d-type.m4 | |||
| @@ -0,0 +1,32 @@ | |||
| 1 | # serial 12 | ||
| 2 | |||
| 3 | dnl From Jim Meyering. | ||
| 4 | dnl | ||
| 5 | dnl Check whether struct dirent has a member named d_type. | ||
| 6 | dnl | ||
| 7 | |||
| 8 | # Copyright (C) 1997, 1999-2004, 2006, 2009-2017 Free Software Foundation, Inc. | ||
| 9 | # | ||
| 10 | # This file is free software; the Free Software Foundation | ||
| 11 | # gives unlimited permission to copy and/or distribute it, | ||
| 12 | # with or without modifications, as long as this notice is preserved. | ||
| 13 | |||
| 14 | AC_DEFUN([gl_CHECK_TYPE_STRUCT_DIRENT_D_TYPE], | ||
| 15 | [AC_CACHE_CHECK([for d_type member in directory struct], | ||
| 16 | [gl_cv_struct_dirent_d_type], | ||
| 17 | [AC_LINK_IFELSE([AC_LANG_PROGRAM([[ | ||
| 18 | #include <sys/types.h> | ||
| 19 | #include <dirent.h> | ||
| 20 | ]], | ||
| 21 | [[struct dirent dp; dp.d_type = 0;]])], | ||
| 22 | [gl_cv_struct_dirent_d_type=yes], | ||
| 23 | [gl_cv_struct_dirent_d_type=no]) | ||
| 24 | ] | ||
| 25 | ) | ||
| 26 | if test $gl_cv_struct_dirent_d_type = yes; then | ||
| 27 | AC_DEFINE([HAVE_STRUCT_DIRENT_D_TYPE], [1], | ||
| 28 | [Define if there is a member named d_type in the struct describing | ||
| 29 | directory headers.]) | ||
| 30 | fi | ||
| 31 | ] | ||
| 32 | ) | ||
diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4 index 2f135773930..188c116c851 100644 --- a/m4/gnulib-comp.m4 +++ b/m4/gnulib-comp.m4 | |||
| @@ -61,6 +61,7 @@ AC_DEFUN([gl_EARLY], | |||
| 61 | # Code from module crypto/sha1: | 61 | # Code from module crypto/sha1: |
| 62 | # Code from module crypto/sha256: | 62 | # Code from module crypto/sha256: |
| 63 | # Code from module crypto/sha512: | 63 | # Code from module crypto/sha512: |
| 64 | # Code from module d-type: | ||
| 64 | # Code from module diffseq: | 65 | # Code from module diffseq: |
| 65 | # Code from module dirent: | 66 | # Code from module dirent: |
| 66 | # Code from module dirfd: | 67 | # Code from module dirfd: |
| @@ -199,6 +200,7 @@ AC_DEFUN([gl_INIT], | |||
| 199 | gl_SHA1 | 200 | gl_SHA1 |
| 200 | gl_SHA256 | 201 | gl_SHA256 |
| 201 | gl_SHA512 | 202 | gl_SHA512 |
| 203 | gl_CHECK_TYPE_STRUCT_DIRENT_D_TYPE | ||
| 202 | gl_DIRENT_H | 204 | gl_DIRENT_H |
| 203 | AC_REQUIRE([gl_C99_STRTOLD]) | 205 | AC_REQUIRE([gl_C99_STRTOLD]) |
| 204 | gl_FUNC_DUP2 | 206 | gl_FUNC_DUP2 |
| @@ -968,6 +970,7 @@ AC_DEFUN([gl_FILE_LIST], [ | |||
| 968 | m4/count-leading-zeros.m4 | 970 | m4/count-leading-zeros.m4 |
| 969 | m4/count-one-bits.m4 | 971 | m4/count-one-bits.m4 |
| 970 | m4/count-trailing-zeros.m4 | 972 | m4/count-trailing-zeros.m4 |
| 973 | m4/d-type.m4 | ||
| 971 | m4/dirent_h.m4 | 974 | m4/dirent_h.m4 |
| 972 | m4/dirfd.m4 | 975 | m4/dirfd.m4 |
| 973 | m4/dup2.m4 | 976 | m4/dup2.m4 |