emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] [emacs] 01/01: Attempt to allocate less font entity object


From: Dmitry Antipov
Subject: [Emacs-diffs] [emacs] 01/01: Attempt to allocate less font entity objects in xfont_list_pattern
Date: Fri, 14 Nov 2014 10:42:49 +0000

antipov pushed a commit to branch master
in repository emacs.

commit a5cbb7d9cc072db90201dd6e7e597c424a7d015e
Author: Dmitry Antipov <address@hidden>
Date:   Fri Nov 14 13:40:24 2014 +0300

    Attempt to allocate less font entity objects in xfont_list_pattern
    
    * xfont.c (xfont_list_pattern): Do not allocate font entity object
    for each candidate font but attempt to reuse it from previous improper
    candidate, if any.
---
 src/ChangeLog |    8 +++++++-
 src/xfont.c   |   10 +++++-----
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index 2be24fa..6f105ea 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,9 @@
+2014-11-14  Dmitry Antipov  <address@hidden>
+
+       * xfont.c (xfont_list_pattern): Do not allocate font entity object
+       for each candidate font but attempt to reuse it from previous improper
+       candidate, if any.
+
 2014-11-13  Paul Eggert  <address@hidden>
 
        Avoid undefined behavior in color table hashing.
@@ -237,7 +243,7 @@
        functions in Vselection_converter_alist (Bug#18911).
        (syms_of_nsselect): Remove Vselection_converter_alist.
 
-(2014-10-31  Dmitry Antipov  <address@hidden>
+2014-10-31  Dmitry Antipov  <address@hidden>
 
        * font.c (copy_font_spec): Redesign to avoid Fcopy_alist
        and unnecessary initialization.  Adjust comments.
diff --git a/src/xfont.c b/src/xfont.c
index 5e8dd37..06a4479 100644
--- a/src/xfont.c
+++ b/src/xfont.c
@@ -386,7 +386,7 @@ xfont_list_pattern (Display *display, const char *pattern,
     {
       char **indices = alloca (sizeof (char *) * num_fonts);
       Lisp_Object *props = XVECTOR (xfont_scratch_props)->contents;
-      Lisp_Object scripts = Qnil;
+      Lisp_Object scripts = Qnil, entity = Qnil;
 
       for (i = 0; i < ASIZE (xfont_scratch_props); i++)
        ASET (xfont_scratch_props, i, Qnil);
@@ -397,11 +397,11 @@ xfont_list_pattern (Display *display, const char *pattern,
       for (i = 0; i < num_fonts; i++)
        {
          ptrdiff_t len;
-         Lisp_Object entity;
 
          if (i > 0 && xstrcasecmp (indices[i - 1], indices[i]) == 0)
            continue;
-         entity = font_make_entity ();
+         if (NILP (entity))
+           entity = font_make_entity ();
          len = xfont_decode_coding_xlfd (indices[i], -1, buf);
          if (font_parse_xlfd (buf, len, entity) < 0)
            continue;
@@ -459,7 +459,7 @@ xfont_list_pattern (Display *display, const char *pattern,
            {
              if (NILP (script)
                  || xfont_chars_supported (chars, NULL, encoding, repertory))
-               list = Fcons (entity, list);
+               list = Fcons (entity, list), entity = Qnil;
              continue;
            }
          if (memcmp (props, aref_addr (entity, FONT_FOUNDRY_INDEX),
@@ -474,7 +474,7 @@ xfont_list_pattern (Display *display, const char *pattern,
            }
          if (NILP (script)
              || ! NILP (Fmemq (script, scripts)))
-           list = Fcons (entity, list);
+           list = Fcons (entity, list), entity = Qnil;
        }
       XFreeFontNames (names);
     }



reply via email to

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