all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Robert Pluim <rpluim@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 39133@debbugs.gnu.org, lg.zevlg@gmail.com
Subject: bug#39133: 28.0.50; Emacs slowdown on special char
Date: Fri, 24 Jan 2020 16:41:40 +0100	[thread overview]
Message-ID: <m2d0b8amkr.fsf@gmail.com> (raw)
In-Reply-To: <m2h80l9d65.fsf@gmail.com> (Robert Pluim's message of "Fri, 24 Jan 2020 14:50:10 +0100")

[-- Attachment #1: Type: text/plain, Size: 146 bytes --]

>>>>> On Fri, 24 Jan 2020 14:50:10 +0100, Robert Pluim <rpluim@gmail.com> said:
    Robert> Yes, I worked that out. A simple crash, for once :-)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Don-t-attempt-to-cache-glyph-metrics-for-FONT_INVALI.patch --]
[-- Type: text/x-patch, Size: 3179 bytes --]

From 667f47abecc13e8a47181f338e727d95e57a6354 Mon Sep 17 00:00:00 2001
From: Robert Pluim <rpluim@gmail.com>
Date: Fri, 24 Jan 2020 14:11:44 +0100
Subject: [PATCH] Don't attempt to cache glyph metrics for FONT_INVALID_CODE

This was causing massive slowdown in redisplay when eg #xfe0f
(VARIATION SELECTOR-16) was present, as the cache ended up very large,
unused, and being recreated on every call to font_fill_lglyph_metrics
(Bug#39133).

* src/composite.c (fill_gstring_body): Hoist FONT_OBJECT_P check out
of loop.  Calculate glyph code and check for FONT_INVALID_CODE before
calling font_fill_lglyph_metrics.  Pass glyph code to it.

* src/font.c (font_fill_lglyph_metrics): Add code parameter, move
glyph code calculation up the call stack into fill_gstring_body.

* src/font.h: Adjust font_fill_lglyph_metrics prototype.
---
 src/composite.c | 18 ++++++++++++++----
 src/font.c      |  4 +---
 src/font.h      |  2 +-
 3 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/src/composite.c b/src/composite.c
index 53e6930b5f..364d5c9316 100644
--- a/src/composite.c
+++ b/src/composite.c
@@ -818,6 +818,11 @@ fill_gstring_body (Lisp_Object gstring)
   Lisp_Object header = AREF (gstring, 0);
   ptrdiff_t len = LGSTRING_CHAR_LEN (gstring);
   ptrdiff_t i;
+  struct font *font = NULL;
+  unsigned int code;
+
+  if (FONT_OBJECT_P (font_object))
+    font = XFONT_OBJECT (font_object);
 
   for (i = 0; i < len; i++)
     {
@@ -832,10 +837,15 @@ fill_gstring_body (Lisp_Object gstring)
       LGLYPH_SET_FROM (g, i);
       LGLYPH_SET_TO (g, i);
       LGLYPH_SET_CHAR (g, c);
-      if (FONT_OBJECT_P (font_object))
-	{
-	  font_fill_lglyph_metrics (g, font_object);
-	}
+
+      if (font != NULL)
+        code = font->driver->encode_char (font, LGLYPH_CHAR (g));
+      else
+        code = FONT_INVALID_CODE;
+      if (code != FONT_INVALID_CODE)
+        {
+	  font_fill_lglyph_metrics (g, font, code);
+        }
       else
 	{
 	  int width = XFIXNAT (CHAR_TABLE_REF (Vchar_width_table, c));
diff --git a/src/font.c b/src/font.c
index bb39aef92d..2a45630061 100644
--- a/src/font.c
+++ b/src/font.c
@@ -4416,10 +4416,8 @@ DEFUN ("clear-font-cache", Fclear_font_cache, Sclear_font_cache, 0, 0, 0,
 
 \f
 void
-font_fill_lglyph_metrics (Lisp_Object glyph, Lisp_Object font_object)
+font_fill_lglyph_metrics (Lisp_Object glyph, struct font *font, unsigned int code)
 {
-  struct font *font = XFONT_OBJECT (font_object);
-  unsigned code = font->driver->encode_char (font, LGLYPH_CHAR (glyph));
   struct font_metrics metrics;
 
   LGLYPH_SET_CODE (glyph, code);
diff --git a/src/font.h b/src/font.h
index 0561e3c83f..8614e7fa10 100644
--- a/src/font.h
+++ b/src/font.h
@@ -886,7 +886,7 @@ valid_font_driver (struct font_driver const *d)
 extern Lisp_Object font_range (ptrdiff_t, ptrdiff_t, ptrdiff_t *,
 			       struct window *, struct face *,
 			       Lisp_Object);
-extern void font_fill_lglyph_metrics (Lisp_Object, Lisp_Object);
+extern void font_fill_lglyph_metrics (Lisp_Object, struct font *, unsigned int);
 
 extern Lisp_Object font_put_extra (Lisp_Object font, Lisp_Object prop,
                                    Lisp_Object val);
-- 
2.23.0


  reply	other threads:[~2020-01-24 15:41 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-14 13:21 bug#39133: 28.0.50; Emacs slowdown on special char Evgeny Zajcev
2020-01-14 15:26 ` Eli Zaretskii
2020-01-14 16:24   ` Robert Pluim
2020-01-15  4:26     ` YAMAMOTO Mitsuharu
2020-01-15  8:25       ` Robert Pluim
2020-01-15 10:47         ` Evgeny Zajcev
2020-01-15 16:19       ` Eli Zaretskii
2020-01-24 10:13         ` Robert Pluim
2020-01-24 10:22           ` Eli Zaretskii
2020-01-24 13:09             ` Robert Pluim
2020-01-24 13:40               ` Eli Zaretskii
2020-01-24 13:50                 ` Robert Pluim
2020-01-24 15:41                   ` Robert Pluim [this message]
2020-01-24 15:52                     ` Eli Zaretskii
2020-03-02  7:40                       ` Robert Pluim
2020-03-02  8:49                         ` Eli Zaretskii
2020-03-02  9:25                           ` Robert Pluim

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m2d0b8amkr.fsf@gmail.com \
    --to=rpluim@gmail.com \
    --cc=39133@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=lg.zevlg@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.