aboutsummaryrefslogtreecommitdiffstats
path: root/src/lread.c
diff options
context:
space:
mode:
authorEli Zaretskii2012-10-12 17:19:54 +0200
committerEli Zaretskii2012-10-12 17:19:54 +0200
commitbb385a92ec4f8f5bbc93641aaa274bd735826574 (patch)
tree8fff4a185dfc74f91d94edc7b45dcd9dacbfbd67 /src/lread.c
parent605a3df6811c2b3ce9379149cc8fd64fc9846136 (diff)
downloademacs-bb385a92ec4f8f5bbc93641aaa274bd735826574.tar.gz
emacs-bb385a92ec4f8f5bbc93641aaa274bd735826574.zip
Fix bug #12587 with slow startup on MS-Windows with Netlogon service.
src/fileio.c (check_existing): New function. (make_temp_name, Ffile_exists_p, Ffile_writable_p): Call it instead of calling 'stat', when what's needed is to check whether a file exists. This avoids expensive system calls on MS-Windows. src/w32.c (init_environment): Call 'check_existing' instead of 'stat'. src/lread.c (openp) [WINDOWSNT]: Call 'access' instead of 'stat' to determine whether a file exists and is not a directory. src/lisp.h (check_existing): Add prototype.
Diffstat (limited to 'src/lread.c')
-rw-r--r--src/lread.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/lread.c b/src/lread.c
index dbbde694cf6..6d4c0d990af 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -1449,7 +1449,6 @@ openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes, Lisp_Object *sto
1449 bool absolute = 0; 1449 bool absolute = 0;
1450 ptrdiff_t want_length; 1450 ptrdiff_t want_length;
1451 Lisp_Object filename; 1451 Lisp_Object filename;
1452 struct stat st;
1453 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6; 1452 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6;
1454 Lisp_Object string, tail, encoded_fn; 1453 Lisp_Object string, tail, encoded_fn;
1455 ptrdiff_t max_suffix_len = 0; 1454 ptrdiff_t max_suffix_len = 0;
@@ -1543,11 +1542,18 @@ openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes, Lisp_Object *sto
1543 } 1542 }
1544 else 1543 else
1545 { 1544 {
1545#ifndef WINDOWSNT
1546 struct stat st;
1547#endif
1546 const char *pfn; 1548 const char *pfn;
1547 1549
1548 encoded_fn = ENCODE_FILE (string); 1550 encoded_fn = ENCODE_FILE (string);
1549 pfn = SSDATA (encoded_fn); 1551 pfn = SSDATA (encoded_fn);
1552#ifdef WINDOWSNT
1553 exists = access (pfn, F_OK) == 0 && access (pfn, D_OK) < 0;
1554#else
1550 exists = (stat (pfn, &st) == 0 && ! S_ISDIR (st.st_mode)); 1555 exists = (stat (pfn, &st) == 0 && ! S_ISDIR (st.st_mode));
1556#endif
1551 if (exists) 1557 if (exists)
1552 { 1558 {
1553 /* Check that we can access or open it. */ 1559 /* Check that we can access or open it. */