emacs-diffs
[Top][All Lists]
Advanced

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

feature/native-comp 5aa42f6: Prevent unnecessary multiple .el hashing in


From: Andrea Corallo
Subject: feature/native-comp 5aa42f6: Prevent unnecessary multiple .el hashing in 'maybe_swap_for_eln'
Date: Sun, 21 Mar 2021 16:08:44 -0400 (EDT)

branch: feature/native-comp
commit 5aa42f686c635e3b3f6cea8270e3c6fc2e4270f9
Author: Andrea Corallo <akrl@sdf.org>
Commit: Andrea Corallo <akrl@sdf.org>

    Prevent unnecessary multiple .el hashing in 'maybe_swap_for_eln'
    
        * src/comp.c (Fcomp_el_to_eln_rel_filename): New function.
        (Fcomp_el_to_eln_filename): Make use of.
        (syms_of_comp): Register 'Scomp_el_to_eln_rel_filename'.
        * src/lread.c (maybe_swap_for_eln): Make use of
        'Fcomp_el_to_eln_rel_filename' to hash prevent unnecessary
        multiple hashing.
---
 src/comp.c  | 21 +++++++++++++++------
 src/lread.c | 22 ++++++++++++----------
 2 files changed, 27 insertions(+), 16 deletions(-)

diff --git a/src/comp.c b/src/comp.c
index 29b16c7..4e2b941 100644
--- a/src/comp.c
+++ b/src/comp.c
@@ -4001,11 +4001,10 @@ make_directory_wrapper_1 (Lisp_Object ignore)
   return Qt;
 }
 
-DEFUN ("comp-el-to-eln-filename", Fcomp_el_to_eln_filename,
-       Scomp_el_to_eln_filename, 1, 2, 0,
-       doc: /* Return the corresponding .eln filename for source FILENAME.
-If BASE-DIR is nil use the first entry in `comp-eln-load-path'.  */)
-  (Lisp_Object filename, Lisp_Object base_dir)
+DEFUN ("comp-el-to-eln-rel-filename", Fcomp_el_to_eln_rel_filename,
+       Scomp_el_to_eln_rel_filename, 1, 1, 0,
+       doc: /* Return the corresponding .eln relative filename.  */)
+  (Lisp_Object filename)
 {
   CHECK_STRING (filename);
 
@@ -4082,7 +4081,16 @@ If BASE-DIR is nil use the first entry in 
`comp-eln-load-path'.  */)
                                                           make_fixnum (-3))),
                      separator);
   Lisp_Object hash = concat3 (path_hash, separator, content_hash);
-  filename = concat3 (filename, hash, build_string (NATIVE_ELISP_SUFFIX));
+  return concat3 (filename, hash, build_string (NATIVE_ELISP_SUFFIX));
+}
+
+DEFUN ("comp-el-to-eln-filename", Fcomp_el_to_eln_filename,
+       Scomp_el_to_eln_filename, 1, 2, 0,
+       doc: /* Return the corresponding .eln filename for source FILENAME.
+If BASE-DIR is nil use the first entry in `comp-eln-load-path'.  */)
+  (Lisp_Object filename, Lisp_Object base_dir)
+{
+  filename = Fcomp_el_to_eln_rel_filename (filename);
 
   /* If base_dir was not specified search inside Vcomp_eln_load_path
      for the first directory where we have write access.  */
@@ -5287,6 +5295,7 @@ compiled one.  */);
                             "configuration, please recompile"));
 
   defsubr (&Scomp__subr_signature);
+  defsubr (&Scomp_el_to_eln_rel_filename);
   defsubr (&Scomp_el_to_eln_filename);
   defsubr (&Scomp_native_driver_options_effective_p);
   defsubr (&Scomp__install_trampoline);
diff --git a/src/lread.c b/src/lread.c
index 3bf3150..5fd52fe 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -1661,19 +1661,21 @@ maybe_swap_for_eln (bool no_native, Lisp_Object 
*filename, int *fd)
 
   /* Search eln in the eln-cache directories.  */
   Lisp_Object eln_path_tail = Vcomp_eln_load_path;
-  FOR_EACH_TAIL_SAFE (eln_path_tail)
+  Lisp_Object src_name =
+    Fsubstring (*filename, Qnil, make_fixnum (-1));
+  if (NILP (Ffile_exists_p (src_name)))
     {
-      Lisp_Object src_name =
-       Fsubstring (*filename, Qnil, make_fixnum (-1));
+      src_name = concat2 (src_name, build_string (".gz"));
       if (NILP (Ffile_exists_p (src_name)))
-       {
-         src_name = concat2 (src_name, build_string (".gz"));
-         if (NILP (Ffile_exists_p (src_name)))
-           /* Can't find the corresponding source file.  */
-           return;
-       }
+       /* Can't find the corresponding source file.  */
+       return;
+    }
+  Lisp_Object eln_rel_name = Fcomp_el_to_eln_rel_filename (src_name);
+
+  FOR_EACH_TAIL_SAFE (eln_path_tail)
+    {
       Lisp_Object eln_name =
-       Fcomp_el_to_eln_filename (src_name, XCAR (eln_path_tail));
+       Fexpand_file_name (eln_rel_name, XCAR (eln_path_tail));
       int eln_fd = emacs_open (SSDATA (ENCODE_FILE (eln_name)), O_RDONLY, 0);
 
       if (eln_fd > 0)



reply via email to

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