Commit a5cbb7d9 authored by Dmitry Antipov's avatar Dmitry Antipov
Browse files

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.
parent eb976992
2014-11-14 Dmitry Antipov <dmantipov@yandex.ru>
* 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 <eggert@cs.ucla.edu> 2014-11-13 Paul Eggert <eggert@cs.ucla.edu>
   
Avoid undefined behavior in color table hashing. Avoid undefined behavior in color table hashing.
...@@ -237,7 +243,7 @@ ...@@ -237,7 +243,7 @@
functions in Vselection_converter_alist (Bug#18911). functions in Vselection_converter_alist (Bug#18911).
(syms_of_nsselect): Remove Vselection_converter_alist. (syms_of_nsselect): Remove Vselection_converter_alist.
   
(2014-10-31 Dmitry Antipov <dmantipov@yandex.ru> 2014-10-31 Dmitry Antipov <dmantipov@yandex.ru>
   
* font.c (copy_font_spec): Redesign to avoid Fcopy_alist * font.c (copy_font_spec): Redesign to avoid Fcopy_alist
and unnecessary initialization. Adjust comments. and unnecessary initialization. Adjust comments.
......
...@@ -386,7 +386,7 @@ xfont_list_pattern (Display *display, const char *pattern, ...@@ -386,7 +386,7 @@ xfont_list_pattern (Display *display, const char *pattern,
{ {
char **indices = alloca (sizeof (char *) * num_fonts); char **indices = alloca (sizeof (char *) * num_fonts);
Lisp_Object *props = XVECTOR (xfont_scratch_props)->contents; 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++) for (i = 0; i < ASIZE (xfont_scratch_props); i++)
ASET (xfont_scratch_props, i, Qnil); ASET (xfont_scratch_props, i, Qnil);
...@@ -397,11 +397,11 @@ xfont_list_pattern (Display *display, const char *pattern, ...@@ -397,11 +397,11 @@ xfont_list_pattern (Display *display, const char *pattern,
for (i = 0; i < num_fonts; i++) for (i = 0; i < num_fonts; i++)
{ {
ptrdiff_t len; ptrdiff_t len;
Lisp_Object entity;
if (i > 0 && xstrcasecmp (indices[i - 1], indices[i]) == 0) if (i > 0 && xstrcasecmp (indices[i - 1], indices[i]) == 0)
continue; continue;
entity = font_make_entity (); if (NILP (entity))
entity = font_make_entity ();
len = xfont_decode_coding_xlfd (indices[i], -1, buf); len = xfont_decode_coding_xlfd (indices[i], -1, buf);
if (font_parse_xlfd (buf, len, entity) < 0) if (font_parse_xlfd (buf, len, entity) < 0)
continue; continue;
...@@ -459,7 +459,7 @@ xfont_list_pattern (Display *display, const char *pattern, ...@@ -459,7 +459,7 @@ xfont_list_pattern (Display *display, const char *pattern,
{ {
if (NILP (script) if (NILP (script)
|| xfont_chars_supported (chars, NULL, encoding, repertory)) || xfont_chars_supported (chars, NULL, encoding, repertory))
list = Fcons (entity, list); list = Fcons (entity, list), entity = Qnil;
continue; continue;
} }
if (memcmp (props, aref_addr (entity, FONT_FOUNDRY_INDEX), if (memcmp (props, aref_addr (entity, FONT_FOUNDRY_INDEX),
...@@ -474,7 +474,7 @@ xfont_list_pattern (Display *display, const char *pattern, ...@@ -474,7 +474,7 @@ xfont_list_pattern (Display *display, const char *pattern,
} }
if (NILP (script) if (NILP (script)
|| ! NILP (Fmemq (script, scripts))) || ! NILP (Fmemq (script, scripts)))
list = Fcons (entity, list); list = Fcons (entity, list), entity = Qnil;
} }
XFreeFontNames (names); XFreeFontNames (names);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment