branch: externals/marginalia
commit a0e9903bdb63d70a59653f73f77082f20a669b2c
Author: Daniel Mendler <[email protected]>
Commit: Daniel Mendler <[email protected]>
Remove marginalia--annotate-binding-hash (See #16)
I cannot reproduce the allocation problem anymore with Vertico or Selectrum.
Maybe this was due to executing the annotators in a temporary buffer in
Selectrum back then, which lead to flushes of the where-is-internal cache?
---
marginalia.el | 17 ++---------------
1 file changed, 2 insertions(+), 15 deletions(-)
diff --git a/marginalia.el b/marginalia.el
index f052a0d..ffa7155 100644
--- a/marginalia.el
+++ b/marginalia.el
@@ -313,24 +313,11 @@ WIDTH is the format width. This can be specified as
alternative to FORMAT."
(marginalia--fields
(str :truncate marginalia-truncate-width :face
'marginalia-documentation))))
-(defvar-local marginalia--annotate-binding-hash nil
- "Hash table storing the keybinding of every command.
-This hash table is needed to speed up `marginalia-annotate-binding'.")
-
(defun marginalia-annotate-binding (cand)
"Annotate command CAND with keybinding."
- ;; Precomputing the keybinding of every command is faster than looking it up
every time using
- ;; `where-is-internal'. `where-is-internal' generates a lot of garbage,
leading to garbage
- ;; collecting pauses when interacting with the minibuffer. See
- ;; https://github.com/minad/marginalia/issues/16.
- (unless marginalia--annotate-binding-hash
- (setq marginalia--annotate-binding-hash (make-hash-table :size 1025))
- (mapatoms (lambda (sym)
- (when-let (key (and (commandp sym) (where-is-internal sym nil
t)))
- (puthash sym key marginalia--annotate-binding-hash)))))
(when-let* ((sym (intern-soft cand))
- (binding (gethash sym marginalia--annotate-binding-hash)))
- (propertize (format " (%s)" (key-description binding)) 'face
'marginalia-key)))
+ (key (and (commandp sym) (where-is-internal sym nil
'first-only))))
+ (propertize (format " (%s)" (key-description key)) 'face 'marginalia-key)))
(defun marginalia--annotator (cat)
"Return annotation function for category CAT."