emacs-devel
[Top][All Lists]
Advanced

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

Re: Entering emojis


From: Lars Ingebrigtsen
Subject: Re: Entering emojis
Date: Fri, 29 Oct 2021 22:43:23 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

Eli Zaretskii <eliz@gnu.org> writes:

>  . Then, for each character you want to test for being displayable,
>    do this:
>
>       (font-get-glyphs FONT-OBJECT 0 1 '[CODEPOINT])
>
>    where FONT-OBJECT is the car of the value returned by
>    internal-char-font, and CODEPOINT is the character you want to test
>    for being displayable, for example #x1f600.  If this returns nil,
>    that character is not supported by that font.
>
> This should be faster, since it only checks a single font, and the
> expensive call is outside the loop.

Great!  But plugging that into the code seems to yield no difference, so
I tried various strategies to time this.  And in my synthetic tests,
it's way faster.  This takes 0.3s, which is many orders of magnitude
faster than just calling internal-char-font:

(benchmark-run 1
  (let ((font (car (internal-char-font nil ?😀))))
    (dotimes (i 50000)
      (font-get-glyphs font 0 1 (vector i)))))

So I've been trying to profile the code, and with this wrapper:

(defun wrap (a b c d)
  (font-get-glyphs a b c d))

I get this trace:

         114  61% - ...
         103  55%  - emoji--adjust-displayable
         103  55%   - let
         103  55%    - emoji--adjust-displayable-1
         103  55%     - if
         103  55%      - let
         103  55%       - while
         103  55%        - let
         103  55%         - emoji--adjust-displayable-1
         103  55%          - if
          96  52%           - let
          96  52%            - while
          96  52%             - let
          96  52%              - emoji--adjust-displayable-1
          96  52%               - if
          96  52%                - while
          96  52%                 - let
          88  47%                  - if
          88  47%                   - let
          88  47%                    - if
          88  47%                     - elt
          88  47%                        wrap

Which seems to say that all the time is indeed spent in font-get-glyphs.
So I'm scratching my head and poking at this, because something has to
be...  wrong...  I'll be back tomorrow with further results.  :-/

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



reply via email to

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