aboutsummaryrefslogtreecommitdiffstats
path: root/src/xfont.c
diff options
context:
space:
mode:
authorDmitry Antipov2014-11-14 13:40:24 +0300
committerDmitry Antipov2014-11-14 13:40:24 +0300
commita5cbb7d9cc072db90201dd6e7e597c424a7d015e (patch)
treef2fb93ecad8d075bf772506428fa2a29b29ee6e5 /src/xfont.c
parenteb976992367d5b265dc779d82af5948987ec6de3 (diff)
downloademacs-a5cbb7d9cc072db90201dd6e7e597c424a7d015e.tar.gz
emacs-a5cbb7d9cc072db90201dd6e7e597c424a7d015e.zip
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.
Diffstat (limited to 'src/xfont.c')
-rw-r--r--src/xfont.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/xfont.c b/src/xfont.c
index 5e8dd370120..06a44794364 100644
--- a/src/xfont.c
+++ b/src/xfont.c
@@ -386,7 +386,7 @@ xfont_list_pattern (Display *display, const char *pattern,
386 { 386 {
387 char **indices = alloca (sizeof (char *) * num_fonts); 387 char **indices = alloca (sizeof (char *) * num_fonts);
388 Lisp_Object *props = XVECTOR (xfont_scratch_props)->contents; 388 Lisp_Object *props = XVECTOR (xfont_scratch_props)->contents;
389 Lisp_Object scripts = Qnil; 389 Lisp_Object scripts = Qnil, entity = Qnil;
390 390
391 for (i = 0; i < ASIZE (xfont_scratch_props); i++) 391 for (i = 0; i < ASIZE (xfont_scratch_props); i++)
392 ASET (xfont_scratch_props, i, Qnil); 392 ASET (xfont_scratch_props, i, Qnil);
@@ -397,11 +397,11 @@ xfont_list_pattern (Display *display, const char *pattern,
397 for (i = 0; i < num_fonts; i++) 397 for (i = 0; i < num_fonts; i++)
398 { 398 {
399 ptrdiff_t len; 399 ptrdiff_t len;
400 Lisp_Object entity;
401 400
402 if (i > 0 && xstrcasecmp (indices[i - 1], indices[i]) == 0) 401 if (i > 0 && xstrcasecmp (indices[i - 1], indices[i]) == 0)
403 continue; 402 continue;
404 entity = font_make_entity (); 403 if (NILP (entity))
404 entity = font_make_entity ();
405 len = xfont_decode_coding_xlfd (indices[i], -1, buf); 405 len = xfont_decode_coding_xlfd (indices[i], -1, buf);
406 if (font_parse_xlfd (buf, len, entity) < 0) 406 if (font_parse_xlfd (buf, len, entity) < 0)
407 continue; 407 continue;
@@ -459,7 +459,7 @@ xfont_list_pattern (Display *display, const char *pattern,
459 { 459 {
460 if (NILP (script) 460 if (NILP (script)
461 || xfont_chars_supported (chars, NULL, encoding, repertory)) 461 || xfont_chars_supported (chars, NULL, encoding, repertory))
462 list = Fcons (entity, list); 462 list = Fcons (entity, list), entity = Qnil;
463 continue; 463 continue;
464 } 464 }
465 if (memcmp (props, aref_addr (entity, FONT_FOUNDRY_INDEX), 465 if (memcmp (props, aref_addr (entity, FONT_FOUNDRY_INDEX),
@@ -474,7 +474,7 @@ xfont_list_pattern (Display *display, const char *pattern,
474 } 474 }
475 if (NILP (script) 475 if (NILP (script)
476 || ! NILP (Fmemq (script, scripts))) 476 || ! NILP (Fmemq (script, scripts)))
477 list = Fcons (entity, list); 477 list = Fcons (entity, list), entity = Qnil;
478 } 478 }
479 XFreeFontNames (names); 479 XFreeFontNames (names);
480 } 480 }