[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] trunk r118240: * font.c (copy_font_spec): Redesign to avoi
From: |
Dmitry Antipov |
Subject: |
[Emacs-diffs] trunk r118240: * font.c (copy_font_spec): Redesign to avoid Fcopy_alist |
Date: |
Fri, 31 Oct 2014 11:09:20 +0000 |
User-agent: |
Bazaar (2.6b2) |
------------------------------------------------------------
revno: 118240
revision-id: address@hidden
parent: address@hidden
committer: Dmitry Antipov <address@hidden>
branch nick: trunk
timestamp: Fri 2014-10-31 14:09:00 +0300
message:
* font.c (copy_font_spec): Redesign to avoid Fcopy_alist
and unnecessary initialization. Adjust comments.
modified:
src/ChangeLog changelog-20091113204419-o5vbwnq5f7feedwu-1438
src/font.c font.c-20091113204419-o5vbwnq5f7feedwu-8540
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog 2014-10-30 16:51:53 +0000
+++ b/src/ChangeLog 2014-10-31 11:09:00 +0000
@@ -1,3 +1,8 @@
+2014-10-31 Dmitry Antipov <address@hidden>
+
+ * font.c (copy_font_spec): Redesign to avoid Fcopy_alist
+ and unnecessary initialization. Adjust comments.
+
2014-10-30 Eli Zaretskii <address@hidden>
* bidi.c (bidi_cache_reset_to): Invalidate bidi_cache_last_idx by
=== modified file 'src/font.c'
--- a/src/font.c 2014-10-12 20:09:15 +0000
+++ b/src/font.c 2014-10-31 11:09:00 +0000
@@ -3944,29 +3944,37 @@
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
copy_font_spec (Lisp_Object font)
{
- Lisp_Object new_spec, tail, prev, extra;
- int i;
+ enum { font_spec_size = VECSIZE (struct font_spec) };
+ Lisp_Object new_spec, tail, *pcdr;
+ struct font_spec *spec;
CHECK_FONT (font);
- new_spec = font_make_spec ();
- for (i = 1; i < FONT_EXTRA_INDEX; i++)
- ASET (new_spec, i, AREF (font, i));
- extra = Fcopy_alist (AREF (font, FONT_EXTRA_INDEX));
- /* We must remove :font-entity property. */
- for (prev = Qnil, tail = extra; CONSP (tail); prev = tail, tail = XCDR
(tail))
- if (EQ (XCAR (XCAR (tail)), QCfont_entity))
- {
- if (NILP (prev))
- extra = XCDR (extra);
- else
- XSETCDR (prev, XCDR (tail));
- break;
- }
- ASET (new_spec, FONT_EXTRA_INDEX, extra);
+
+ /* Make an uninitialized font-spec object. */
+ spec = (struct font_spec *) allocate_vector (font_spec_size);
+ XSETPVECTYPESIZE (spec, PVEC_FONT, FONT_SPEC_MAX,
+ font_spec_size - FONT_SPEC_MAX);
+
+ spec->props[FONT_TYPE_INDEX] = spec->props[FONT_EXTRA_INDEX] = Qnil;
+
+ /* Copy basic properties FONT_FOUNDRY_INDEX..FONT_AVGWIDTH_INDEX. */
+ memcpy (spec->props + 1, XVECTOR (font)->contents + 1,
+ (FONT_EXTRA_INDEX - 1) * word_size);
+
+ /* Copy an alist of extra information but discard :font-entity property. */
+ pcdr = spec->props + FONT_EXTRA_INDEX;
+ 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;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] trunk r118240: * font.c (copy_font_spec): Redesign to avoid Fcopy_alist,
Dmitry Antipov <=