From d1cc4a78c362fffc6ff21dbb27b9c096214bc03a Mon Sep 17 00:00:00 2001 From: Jeremy Dormitzer Date: Mon, 23 Mar 2020 10:09:55 -0400 Subject: [PATCH] Add a cache for centaur-tabs icons --- emacs/init.org | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/emacs/init.org b/emacs/init.org index 5dd7516..a16e276 100755 --- a/emacs/init.org +++ b/emacs/init.org @@ -2346,6 +2346,18 @@ UI-related keybindings: (format " %s" title)) (format " %s" title)) (apply oldfn tab args)))) + + ;; Add a cache to speed up icon rendering for huge groups + (defvar centaur-tabs-icon-cache (make-hash-table :test 'equal) + "A cache holding icons generated for centaur-tabs mode tabs.") + (advice-add 'centaur-tabs-icon :around + (lambda (oldfn tab face selected &rest args) + (let ((key (list tab face selected))) + (or (gethash key centaur-tabs-icon-cache) + (puthash key + (apply oldfn tab face selected args) + centaur-tabs-icon-cache))))) + :general ((normal motion visual) "g t" #'centaur-tabs-forward) ((normal motion visual) "g T" #'centaur-tabs-backward)