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

* font.c (copy_font_spec): Redesign to avoid Fcopy_alist

and unnecessary initialization.  Adjust comments.
parent b77b9254
2014-10-31 Dmitry Antipov <dmantipov@yandex.ru>
* font.c (copy_font_spec): Redesign to avoid Fcopy_alist
and unnecessary initialization. Adjust comments.
2014-10-30 Eli Zaretskii <eliz@gnu.org> 2014-10-30 Eli Zaretskii <eliz@gnu.org>
   
* bidi.c (bidi_cache_reset_to): Invalidate bidi_cache_last_idx by * bidi.c (bidi_cache_reset_to): Invalidate bidi_cache_last_idx by
......
...@@ -3944,29 +3944,37 @@ usage: (font-spec ARGS...) */) ...@@ -3944,29 +3944,37 @@ usage: (font-spec ARGS...) */)
return spec; return spec;
} }
/* Return a copy of FONT as a font-spec. */ /* Return a copy of FONT as a font-spec. For the sake of speed, this code
relies on an internal stuff exposed from alloc.c and should be handled
with care. */
Lisp_Object Lisp_Object
copy_font_spec (Lisp_Object font) copy_font_spec (Lisp_Object font)
{ {
Lisp_Object new_spec, tail, prev, extra; enum { font_spec_size = VECSIZE (struct font_spec) };
int i; Lisp_Object new_spec, tail, *pcdr;
struct font_spec *spec;
CHECK_FONT (font); CHECK_FONT (font);
new_spec = font_make_spec ();
for (i = 1; i < FONT_EXTRA_INDEX; i++) /* Make an uninitialized font-spec object. */
ASET (new_spec, i, AREF (font, i)); spec = (struct font_spec *) allocate_vector (font_spec_size);
extra = Fcopy_alist (AREF (font, FONT_EXTRA_INDEX)); XSETPVECTYPESIZE (spec, PVEC_FONT, FONT_SPEC_MAX,
/* We must remove :font-entity property. */ font_spec_size - FONT_SPEC_MAX);
for (prev = Qnil, tail = extra; CONSP (tail); prev = tail, tail = XCDR (tail))
if (EQ (XCAR (XCAR (tail)), QCfont_entity)) spec->props[FONT_TYPE_INDEX] = spec->props[FONT_EXTRA_INDEX] = Qnil;
{
if (NILP (prev)) /* Copy basic properties FONT_FOUNDRY_INDEX..FONT_AVGWIDTH_INDEX. */
extra = XCDR (extra); memcpy (spec->props + 1, XVECTOR (font)->contents + 1,
else (FONT_EXTRA_INDEX - 1) * word_size);
XSETCDR (prev, XCDR (tail));
break; /* Copy an alist of extra information but discard :font-entity property. */
} pcdr = spec->props + FONT_EXTRA_INDEX;
ASET (new_spec, FONT_EXTRA_INDEX, extra); for (tail = AREF (font, FONT_EXTRA_INDEX); CONSP (tail); tail = XCDR (tail))
if (!EQ (XCAR (XCAR (tail)), QCfont_entity))
*pcdr = Fcons (XCAR (tail), Qnil), pcdr = xcdr_addr (*pcdr);
XSETFONT (new_spec, spec);
return new_spec; return new_spec;
} }
......
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