[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
scratch/native-comp-eln-caches 94666b0 4/6: * Memoize eln cache dirs con
From: |
Andrea Corallo |
Subject: |
scratch/native-comp-eln-caches 94666b0 4/6: * Memoize eln cache dirs content during search to access those once |
Date: |
Sat, 15 Aug 2020 06:35:46 -0400 (EDT) |
branch: scratch/native-comp-eln-caches
commit 94666b0a2b5e17dc93cd09378845efba9102ba88
Author: Andrea Corallo <akrl@sdf.org>
Commit: Andrea Corallo <akrl@sdf.org>
* Memoize eln cache dirs content during search to access those once
* src/lread.c (openp): Define an a-list 'eln_caches_mem' and
use it in order to memoize the eln cache dirs content.
---
src/lread.c | 29 ++++++++++++++++++++++++-----
1 file changed, 24 insertions(+), 5 deletions(-)
diff --git a/src/lread.c b/src/lread.c
index 4ab21ab..7b1e43b 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -1672,6 +1672,11 @@ openp (Lisp_Object path, Lisp_Object str, Lisp_Object
suffixes,
if (NILP (path))
path = just_use_str;
+#ifdef HAVE_NATIVE_COMP
+ /* A-list eln cache dir -> contentained files. */
+ Lisp_Object eln_caches_mem = Qnil;
+#endif
+
/* Go through all entries in the path and see whether we find the
executable. */
FOR_EACH_TAIL_SAFE (path)
@@ -1746,22 +1751,36 @@ openp (Lisp_Object path, Lisp_Object str, Lisp_Object
suffixes,
#ifdef HAVE_NATIVE_COMP
if (suffix_p (string, ".elc"))
{
- /* Search eln in the eln-cache directories. */
+ /* Search for a matching eln file in the eln-cache
+ directories. If a suitable eln is found replace the
+ value of 'string' with it to have it loaded. */
Lisp_Object eln_path_tail = Vcomp_eln_load_path;
FOR_EACH_TAIL_SAFE (eln_path_tail)
{
+ Lisp_Object dir =
+ concat2 (XCAR (eln_path_tail), Vcomp_native_path_postfix);
Lisp_Object el_name =
Fsubstring (string, Qnil, make_fixnum (-1));
Lisp_Object eln_name =
Fcomp_el_to_eln_filename (el_name, XCAR (eln_path_tail));
- /* FIXME memoize using Fdirectory_files */
- if (!NILP (Ffile_exists_p (eln_name))
+ Lisp_Object eln_name_nodir = Ffile_name_nondirectory (eln_name);
+ Lisp_Object files = CDR_SAFE (Fassoc (dir, eln_caches_mem,
Qnil));
+ if (NILP (files))
+ {
+ if (NILP (Ffile_exists_p (dir)))
+ files = Qt;
+ else
+ files = Fdirectory_files (dir, Qnil, Qnil, Qt);
+ eln_caches_mem =
+ Fcons (Fcons (dir, files), eln_caches_mem);
+ }
+ if (CONSP (files)
+ && !NILP (Fmember (eln_name_nodir, files))
&& !NILP (Ffile_newer_than_file_p (eln_name, string)))
{
string = eln_name;
/* Store the eln -> el relation. */
- Fputhash (Ffile_name_nondirectory (eln_name),
- el_name, Vcomp_eln_to_el_h);
+ Fputhash (eln_name_nodir, el_name, Vcomp_eln_to_el_h);
break;
}
}
- branch scratch/native-comp-eln-caches created (now 2f06162), Andrea Corallo, 2020/08/15
- scratch/native-comp-eln-caches ed5c35b 2/6: Make comp-deferred-compilation a simple global and set it on by default, Andrea Corallo, 2020/08/15
- scratch/native-comp-eln-caches 94666b0 4/6: * Memoize eln cache dirs content during search to access those once,
Andrea Corallo <=
- scratch/native-comp-eln-caches 8730fa2 3/6: Some make files update and clean-up, Andrea Corallo, 2020/08/15
- scratch/native-comp-eln-caches 83aa965 5/6: * Prevent recursive load, Andrea Corallo, 2020/08/15
- scratch/native-comp-eln-caches 2f06162 6/6: * Do not fail if more then one level of directories has to be created, Andrea Corallo, 2020/08/15
- scratch/native-comp-eln-caches 2d9bd47 1/6: Move eln files into dedicated cache directories, Andrea Corallo, 2020/08/15