`struct composition` kept an index into the internal `key_and_value` array
of hash tables, which only worked because of details of how
hash-tables are handled. Replace it with a reference to the
key stored at that location in the hash-table, which saves us an
indirection while at it.
* src/composite.h (struct composition): Replace `hash_index` with
the actual `key`.
(COMPOSITION_KEY): Simplify accordingly.
(mark_composite): Declare.
* src/composite.c (get_composition_id): Adjust accordingly.
(mark_composite): New function.
* src/charset.c (mark_charset): Uncomment.
* src/lisp.h (mark_charset): Declare.
* src/alloc.c (garbage_collect): Call `mark_charset` and `mark_composite`.
* src/pdumper.c (hash_table_contents): Remove invalid comment, since
compositions aren't dumped.
(cherry picked from commit
cc861fc528b49fc459bb9a1e5054f5fd82e1b689)
mark_terminals ();
mark_kboards ();
mark_threads ();
+ mark_charset ();
+ mark_composite ();
mark_profiler ();
#ifdef HAVE_PGTK
mark_pgtkterm ();
}
/* Not strictly necessary, because all charset attributes are also
- reachable from `Vcharset_hash_table`.
+ reachable from `Vcharset_hash_table`. */
void
mark_charset (void)
{
for (int i = 0; i < charset_table_used; i++)
mark_object (charset_table[i].attributes);
}
-*/
\f
void
cmp = xmalloc (sizeof *cmp);
cmp->method = method;
- cmp->hash_index = hash_index;
+ cmp->key = key;
cmp->glyph_len = glyph_len;
cmp->offsets = xnmalloc (glyph_len, 2 * sizeof *cmp->offsets);
cmp->font = NULL;
composition_gstring_from_id (ptrdiff_t id)
{
struct Lisp_Hash_Table *h = XHASH_TABLE (gstring_hash_table);
-
+ /* FIXME: The stability of this value depends on the hash table internals! */
return HASH_VALUE (h, id);
}
}
\f
+/* Not strictly necessary, because all those "keys" are also
+ reachable from `composition_hash_table`. */
+void
+mark_composite (void)
+{
+ for (int i = 0; i < n_compositions; i++)
+ mark_object (composition_table[i]->key);
+}
+
+
void
syms_of_composite (void)
{
? XCDR (XCDR (XCDR (prop))) \
: CONSP (prop) ? XCDR (prop) : Qnil)
-#define COMPOSITION_KEY(cmp) \
- HASH_KEY (XHASH_TABLE (composition_hash_table), (cmp)->hash_index)
+#define COMPOSITION_KEY(cmp) (cmp)->key
/* Return the Nth glyph of composition specified by CMP. CMP is a
pointer to `struct composition'. */
/* Method of the composition. */
enum composition_method method;
- /* Index to the composition hash table. */
- ptrdiff_t hash_index;
+ /* The key under which it's found in the composition hash table. */
+ Lisp_Object key;
/* For which font we have calculated the remaining members. The
actual type is device dependent. */
extern void update_compositions (ptrdiff_t, ptrdiff_t, int);
extern void make_composition_value_copy (Lisp_Object);
extern void syms_of_composite (void);
+extern void mark_composite (void);
extern void compose_text (ptrdiff_t, ptrdiff_t, Lisp_Object, Lisp_Object,
Lisp_Object);
extern void syms_of_character (void);
/* Defined in charset.c. */
+extern void mark_charset (void);
extern void init_charset (void);
extern void init_charset_once (void);
extern void syms_of_charset (void);
* sizeof *key_and_value);
ptrdiff_t n = 0;
- /* Make sure key_and_value ends up in the same order; the `hash_index`
- field of `struct composition` relies on it by expecting hash table
- indices to stay constant across the dump.
- FIXME: Remove such dependency on hash table internals (there might
- be another one in `composition_gstring_from_id`). */
DOHASH (h, k, v)
{
key_and_value[n++] = k;