[Top][All Lists]

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

bug#19390: Acknowledgement (25.0.50; `package-activate' is too slow)

From: Dmitry Gutov
Subject: bug#19390: Acknowledgement (25.0.50; `package-activate' is too slow)
Date: Tue, 16 Dec 2014 02:41:58 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0

Here's one possible fix. We don't deal with the slowness of `package--list-loaded-files' at all, and instead only load them if `package-activate' had been called with non-nil second argument (which only happens now if the package is installed).

This also changes the way `package-activate' calls itself recursively on dependencies: instead of always passing the version as the second argument, pass the same value of FORCE it's been called with. Passing the version seems to be a remnant of older code.

diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index cd948ae..394efc3 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -516,7 +516,7 @@ Return the max version (as a string) if the package is held at a lower version."
           (t (error "Invalid element in `package-load-list'")))))

-(defun package-activate-1 (pkg-desc)
+(defun package-activate-1 (pkg-desc &optional force)
   (let* ((name (package-desc-name pkg-desc))
         (pkg-dir (package-desc-dir pkg-desc))
          (pkg-dir-dir (file-name-as-directory pkg-dir)))
@@ -527,7 +527,7 @@ Return the max version (as a string) if the package is held at a lower version."
     (let* ((old-lp load-path)
            (autoloads-file (expand-file-name
                             (format "%s-autoloads" name) pkg-dir))
-           (loaded-files-list (package--list-loaded-files pkg-dir)))
+ (loaded-files-list (and force (package--list-loaded-files pkg-dir))))
       (with-demoted-errors (format "Error loading %s: %%s" name)
         (load autoloads-file nil t))
       (when (and (eq old-lp load-path)
@@ -636,14 +636,14 @@ If FORCE is true, (re-)activate it if it's already activated."
              (fail (catch 'dep-failure
                      ;; Activate its dependencies recursively.
                      (dolist (req (package-desc-reqs pkg-vec))
-                       (unless (package-activate (car req) (cadr req))
+                       (unless (package-activate (car req) force)
                          (throw 'dep-failure req))))))
        (if fail
            (warn "Unable to activate package `%s'.
 Required package `%s-%s' is unavailable"
                  package (car fail) (package-version-join (cadr fail)))
          ;; If all goes well, activate the package itself.
-         (package-activate-1 pkg-vec)))))))
+         (package-activate-1 pkg-vec force)))))))

 (defun define-package (_name-string _version-string
                                     &optional _docstring _requirements

reply via email to

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