mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-06-14 12:31:25 +00:00
Replace 'package--builtin-alist' function with constant
* lisp/emacs-lisp/package.el (package--builtin-alist): (package--upgradeable-packages, package--mapc) (package-get-descriptor): * lisp/emacs-lisp/package.el (package--builtin-alist): Replace function with constant, as the result of the function is always the same within an Emacs session, since the set of built-in packages don't change during execution. (package--upgradeable-packages, package--mapc) (package-get-descriptor): Use variable instead of function. (package-menu--refresh, describe-package-1): Lookup desc in alist instead of calling 'package--from-builtin'. (Bug#80902)
This commit is contained in:
parent
4acb0f775d
commit
931e04a34b
1 changed files with 18 additions and 24 deletions
|
|
@ -468,11 +468,12 @@ BI-DESC should be a `package--bi-desc' object."
|
|||
:summary (package--bi-desc-summary bi-desc)
|
||||
:dir 'builtin))
|
||||
|
||||
(defun package--builtin-alist ()
|
||||
"Return a `package-alist'-like alist for all builtin packages."
|
||||
(defconst package--builtin-alist
|
||||
(cl-loop for bi-desc in package--builtins
|
||||
unless (assq (car bi-desc) package-alist)
|
||||
collect (list (car bi-desc) (package--from-builtin bi-desc))))
|
||||
unless (eq (car bi-desc) 'emacs)
|
||||
collect (list (car bi-desc) (package--from-builtin bi-desc)))
|
||||
"Alist of built-in packages in the form of `package-alist'.
|
||||
The alist doesn't include the pseudo-package for Emacs.")
|
||||
|
||||
(defun package-desc-suffix (pkg-desc)
|
||||
"Return file-name extension of package-desc object PKG-DESC.
|
||||
|
|
@ -2166,7 +2167,7 @@ NAME should be a symbol."
|
|||
(package-desc-version (cadr elt))
|
||||
(package-desc-version available)))
|
||||
(not (package-vc-p (cadr elt))))))
|
||||
(nconc (and include-builtins (package--builtin-alist))
|
||||
(nconc (and include-builtins package--builtin-alist)
|
||||
(package--alist)))))
|
||||
|
||||
;;;###autoload
|
||||
|
|
@ -2889,8 +2890,7 @@ Helper function for `describe-package'."
|
|||
(package--print-email-button author)))
|
||||
(let* ((all-pkgs (append (cdr (assq name package-alist))
|
||||
(cdr (assq name package-archive-contents))
|
||||
(and-let* ((bi (assq name package--builtins)))
|
||||
(list (package--from-builtin bi)))))
|
||||
(cdr (assq name package--builtin-alist))))
|
||||
(other-pkgs (delete desc all-pkgs)))
|
||||
(when other-pkgs
|
||||
(package--print-help-section "Other versions"
|
||||
|
|
@ -3456,15 +3456,13 @@ KEYWORDS should be nil or a list of keywords."
|
|||
(push pkg info-list))))))
|
||||
|
||||
;; Built-in packages:
|
||||
(dolist (elt package--builtins)
|
||||
(let ((pkg (package--from-builtin elt))
|
||||
(name (car elt)))
|
||||
(when (not (eq name 'emacs)) ; Hide the `emacs' package.
|
||||
(when (and (package--has-keyword-p pkg keywords)
|
||||
(or package-list-unversioned
|
||||
(package--bi-desc-version (cdr elt)))
|
||||
(or (eq packages t) (memq name packages)))
|
||||
(push pkg info-list)))))
|
||||
(dolist (elt package--builtin-alist)
|
||||
(let ((name (car elt)) (pkg (cadr elt)))
|
||||
(when (and (package--has-keyword-p pkg keywords)
|
||||
(or package-list-unversioned
|
||||
(package-desc-version pkg))
|
||||
(or (eq packages t) (memq name packages)))
|
||||
(push pkg info-list))))
|
||||
|
||||
;; Available and disabled packages:
|
||||
(unless (equal package--old-archive-priorities package-archive-priorities)
|
||||
|
|
@ -3499,18 +3497,14 @@ KEYWORDS should be nil or a list of keywords."
|
|||
(defun package--mapc (function &optional packages)
|
||||
"Call FUNCTION for all known PACKAGES.
|
||||
PACKAGES can be nil or t, which means to display all known
|
||||
packages, or a list of packages.
|
||||
|
||||
Built-in packages are converted with `package--from-builtin'."
|
||||
packages, or a list of packages."
|
||||
(dolist (pkg (if (memq packages '(t nil))
|
||||
(flatten-tree
|
||||
(list (mapcar #'cdr (package--builtin-alist))
|
||||
(list (mapcar #'cdr package--builtin-alist)
|
||||
(mapcar #'cdr (package--archive-contents))
|
||||
(mapcar #'cdr (package--alist))))
|
||||
(mapcar #'package-get-descriptor packages)))
|
||||
(unless (or (package-disabled-p (package-desc-name pkg)
|
||||
(package-desc-version pkg))
|
||||
(eq (package-desc-name pkg) 'emacs)) ;hide pseudo package
|
||||
(unless (package-disabled-p (package-desc-name pkg) (package-desc-version pkg))
|
||||
(funcall function pkg))))
|
||||
|
||||
(defun package--has-keyword-p (desc &optional keywords)
|
||||
|
|
@ -4983,7 +4977,7 @@ and prevents the object from being returned if the predicate returns nil."
|
|||
(delete-dups (ensure-list sources))))
|
||||
(dolist (ent (pcase-exhaustive source
|
||||
('installed (package--alist))
|
||||
('builtin (package--builtin-alist))
|
||||
('builtin package--builtin-alist)
|
||||
('archive (package--archive-contents))))
|
||||
(when (eq (car ent) pkg)
|
||||
(dolist (desc (cdr ent))
|
||||
|
|
|
|||
Loading…
Reference in a new issue