[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 99fbf39d61: Make tool bar caching more sensible
From: |
Lars Ingebrigtsen |
Subject: |
master 99fbf39d61: Make tool bar caching more sensible |
Date: |
Tue, 3 May 2022 12:46:19 -0400 (EDT) |
branch: master
commit 99fbf39d61bf5e3d9618eafced92c2284938632d
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>
Make tool bar caching more sensible
* lisp/tool-bar.el (tool-bar-keymap-cache): Make into a non-weak
EQ hash table, which should be faster and not lose the contents
after a GC (bug#43397).
(tool-bar--flush-cache, tool-bar-make-keymap): Use the terminal
only as the key.
(tool-bar-local-item, tool-bar-local-item-from-menu): Flush the
cache after altering the tool bar.
---
lisp/tool-bar.el | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/lisp/tool-bar.el b/lisp/tool-bar.el
index 1271d1de23..490fd0d332 100644
--- a/lisp/tool-bar.el
+++ b/lisp/tool-bar.el
@@ -89,19 +89,18 @@ functions.")
(declare-function image-mask-p "image.c" (spec &optional frame))
-(defconst tool-bar-keymap-cache (make-hash-table :weakness t :test 'equal))
+(defconst tool-bar-keymap-cache (make-hash-table))
(defun tool-bar--flush-cache ()
- (setf (gethash (cons (frame-terminal) tool-bar-map) tool-bar-keymap-cache)
- nil))
+ (setf (gethash (frame-terminal) tool-bar-keymap-cache) nil))
(defun tool-bar-make-keymap (&optional _ignore)
"Generate an actual keymap from `tool-bar-map'.
Its main job is to figure out which images to use based on the display's
color capability and based on the available image libraries."
- (let ((key (cons (frame-terminal) tool-bar-map)))
- (or (gethash key tool-bar-keymap-cache)
- (puthash key (tool-bar-make-keymap-1) tool-bar-keymap-cache))))
+ (or (gethash (frame-terminal) tool-bar-keymap-cache)
+ (setf (gethash (frame-terminal) tool-bar-keymap-cache)
+ (tool-bar-make-keymap-1))))
(defun tool-bar-make-keymap-1 ()
"Generate an actual keymap from `tool-bar-map', without caching."
@@ -182,6 +181,7 @@ ICON.xbm, using `find-image'."
(let* ((image-exp (tool-bar--image-expression icon)))
(define-key-after map (vector key)
`(menu-item ,(symbol-name key) ,def :image ,image-exp ,@props))
+ (tool-bar--flush-cache)
(force-mode-line-update)))
;;;###autoload
@@ -248,6 +248,7 @@ holds a keymap."
(setq rest (cdr rest)))
(append `(menu-item ,(car defn) ,rest)
(list :image image-exp) props))))
+ (tool-bar--flush-cache)
(force-mode-line-update))))
;;; Set up some global items. Additions/deletions up for grabs.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 99fbf39d61: Make tool bar caching more sensible,
Lars Ingebrigtsen <=