emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

scratch/emoji 8f6baef 2/2: Speed up font checking


From: Lars Ingebrigtsen
Subject: scratch/emoji 8f6baef 2/2: Speed up font checking
Date: Sun, 31 Oct 2021 11:51:42 -0400 (EDT)

branch: scratch/emoji
commit 8f6baef2b1efb47f18d772e3e26c2e73997dd806
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Speed up font checking
---
 lisp/play/emoji.el | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/lisp/play/emoji.el b/lisp/play/emoji.el
index 46980e1..ef63c5c 100644
--- a/lisp/play/emoji.el
+++ b/lisp/play/emoji.el
@@ -269,7 +269,7 @@ character) under point is."
         ;; Remove glyphs we don't have in graphical displays.
         (if (let ((char (elt glyph 0)))
               (if emoji--font
-                  (font-get-glyphs emoji--font 0 1 (vector char))
+                  (font-has-char-p emoji--font char)
                 (when-let ((font (car (internal-char-font nil char))))
                   (setq emoji--font font))))
             (setq alist (cdr alist))
@@ -550,17 +550,19 @@ We prefer the earliest unique letter."
 
 (defun emoji--compute-name (entry)
   "Add example emojis to the name."
-  (let ((name (concat (car entry) " "))
-        (children (emoji--flatten entry))
-        (max 30))
+  (let* ((name (concat (car entry) " "))
+         (children (emoji--flatten entry))
+         (length (length name))
+         (max 30))
     (cl-loop for i from 0 upto 20
              ;; Choose from all the children.
-             while (< (string-width name) max)
+             while (< length max)
              do (cl-loop for child in children
                          for glyph = (elt child i)
-                         while (< (string-width name) max)
+                         while (< length max)
                          when glyph
-                         do (setq name (concat name glyph))))
+                         do (setq name (concat name glyph)
+                                  length (+ length 2))))
     (if (= (length name) max)
         ;; Make an ellipsis signal that we've not exhausted the
         ;; possibilities.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]