Add a cache for centaur-tabs icons

This commit is contained in:
Jeremy Dormitzer 2020-03-23 10:09:55 -04:00
parent 74c769c27b
commit d1cc4a78c3

View File

@ -2346,6 +2346,18 @@ UI-related keybindings:
(format " %s" title)) (format " %s" title))
(format " %s" title)) (format " %s" title))
(apply oldfn tab args)))) (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 :general
((normal motion visual) "g t" #'centaur-tabs-forward) ((normal motion visual) "g t" #'centaur-tabs-forward)
((normal motion visual) "g T" #'centaur-tabs-backward) ((normal motion visual) "g T" #'centaur-tabs-backward)