]> git.eshelyaron.com Git - emacs.git/commitdiff
* src/pdumper.c (dump_do_dump_relocation): Optimize native dump load.
authorAndrea Corallo <akrl@sdf.org>
Sun, 12 Apr 2020 12:06:14 +0000 (13:06 +0100)
committerAndrea Corallo <akrl@sdf.org>
Sun, 12 Apr 2020 15:52:05 +0000 (16:52 +0100)
Check just once if is a local build or Emacs got installed.

src/pdumper.c

index 490f357219d97cf2eb9f2c0875a4f13c4e76d053..bf6bc3a3bc3c1fcf8a076c1a0c8218b9b2e2f8d9 100644 (file)
@@ -5296,15 +5296,25 @@ dump_do_dump_relocation (const uintptr_t dump_base,
 #ifdef HAVE_NATIVE_COMP
     case RELOC_NATIVE_COMP_UNIT:
       {
+       static enum { UNKNOWN, LOCAL_BUILD, INSTALLED } installation_state;
        struct Lisp_Native_Comp_Unit *comp_u =
          dump_ptr (dump_base, reloc_offset);
+
        if (!CONSP (comp_u->file))
          error ("Trying to load incoherent dumped .eln");
+
+       if (installation_state == UNKNOWN)
+         /* Check just once if is a local build or Emacs got installed. */
+         installation_state =
+           NILP (Ffile_exists_p (concat2 (Vinvocation_directory,
+                                          XCAR (comp_u->file))))
+           ? LOCAL_BUILD : INSTALLED;
+
        comp_u->file =
-         NILP (Ffile_exists_p (XCAR (comp_u->file)))
-         ? XCDR (comp_u->file) : XCAR (comp_u->file);
-       comp_u->handle =
-         dynlib_open (SSDATA (concat2 (Vinvocation_directory, comp_u->file)));
+         concat2 (Vinvocation_directory,
+                  installation_state == LOCAL_BUILD
+                  ? XCDR (comp_u->file) : XCAR (comp_u->file));
+       comp_u->handle = dynlib_open (SSDATA (comp_u->file));
        if (!comp_u->handle)
          error ("%s", dynlib_error ());
        load_comp_unit (comp_u, true, false);