Skip to content

Commit e779203

Browse files
committed
feat: Add cache for displayable char
1 parent d3cf9dc commit e779203

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

jcs-modeline.el

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,17 @@
158158
"Convert OBJ to string."
159159
(format "%s" obj))
160160

161+
(defvar jcs-modeline--char-displayable-cache (make-hash-table :test 'equal)
162+
"Cache the displable character.")
163+
161164
(defun jcs-modeline--char-displayable-p (str-or-char)
162165
"Check if STR-OR-CHAR is displayable."
163166
(when-let* ((char (if (stringp str-or-char)
164167
(string-to-char str-or-char)
165168
str-or-char))
166-
((char-displayable-p char)))
169+
(result (or (gethash char jcs-modeline--char-displayable-cache)
170+
(char-displayable-p char))))
171+
(puthash char result jcs-modeline--char-displayable-cache)
167172
str-or-char))
168173

169174
;; TODO: Use function `string-pixel-width' after 29.1

0 commit comments

Comments
 (0)