aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKim F. Storm2002-05-28 09:03:22 +0000
committerKim F. Storm2002-05-28 09:03:22 +0000
commitda46f04f2c88c210ddec0a1acf63868beeb34c63 (patch)
tree578eef63bc454594493063433750942ac5e3ff95 /src
parent8da139bc6a9fd10abc68ab71bc9ccb8ea27fc224 (diff)
downloademacs-da46f04f2c88c210ddec0a1acf63868beeb34c63.tar.gz
emacs-da46f04f2c88c210ddec0a1acf63868beeb34c63.zip
(Fread_file_name_internal): Added brute-force
speed up for using predicate file-directory-p.
Diffstat (limited to 'src')
-rw-r--r--src/fileio.c39
1 files changed, 30 insertions, 9 deletions
diff --git a/src/fileio.c b/src/fileio.c
index dbc5c7d9a54..2f658f9bee0 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -5911,15 +5911,36 @@ DEFUN ("read-file-name-internal", Fread_file_name_internal, Sread_file_name_inte
5911 if (NILP (Vread_file_name_predicate) 5911 if (NILP (Vread_file_name_predicate)
5912 || EQ (Vread_file_name_predicate, Qfile_exists_p)) 5912 || EQ (Vread_file_name_predicate, Qfile_exists_p))
5913 return all; 5913 return all;
5914 GCPRO3 (all, comp, specdir); 5914
5915 count = specpdl_ptr - specpdl; 5915#ifndef VMS
5916 record_unwind_protect (read_file_name_cleanup, current_buffer->directory); 5916 if (EQ (Vread_file_name_predicate, Qfile_directory_p))
5917 current_buffer->directory = realdir; 5917 {
5918 for (comp = Qnil; CONSP (all); all = XCDR (all)) 5918 /* Brute-force speed up for directory checking:
5919 if (!NILP (call1 (Vread_file_name_predicate, XCAR (all)))) 5919 Discard strings which don't end in a slash. */
5920 comp = Fcons (XCAR (all), comp); 5920 for (comp = Qnil; CONSP (all); all = XCDR (all))
5921 unbind_to (count, Qnil); 5921 {
5922 UNGCPRO; 5922 Lisp_Object tem = XCAR (all);
5923 int len;
5924 if (STRINGP (tem) &&
5925 (len = XSTRING (tem)->size, len > 0) &&
5926 IS_DIRECTORY_SEP (XSTRING (tem)->data[len-1]))
5927 comp = Fcons (tem, comp);
5928 }
5929 }
5930 else
5931#endif
5932 {
5933 /* Must do it the hard (and slow) way. */
5934 GCPRO3 (all, comp, specdir);
5935 count = specpdl_ptr - specpdl;
5936 record_unwind_protect (read_file_name_cleanup, current_buffer->directory);
5937 current_buffer->directory = realdir;
5938 for (comp = Qnil; CONSP (all); all = XCDR (all))
5939 if (!NILP (call1 (Vread_file_name_predicate, XCAR (all))))
5940 comp = Fcons (XCAR (all), comp);
5941 unbind_to (count, Qnil);
5942 UNGCPRO;
5943 }
5923 return Fnreverse (comp); 5944 return Fnreverse (comp);
5924 } 5945 }
5925 5946