mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-02-16 09:14:18 +00:00
(struct composition): Remove dependency on hash-table internals
`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.
This commit is contained in:
parent
3018c6e7ba
commit
cc861fc528
6 changed files with 20 additions and 13 deletions
|
|
@ -6594,6 +6594,8 @@ garbage_collect (void)
|
|||
mark_terminals ();
|
||||
mark_kboards ();
|
||||
mark_threads ();
|
||||
mark_charset ();
|
||||
mark_composite ();
|
||||
mark_profiler ();
|
||||
#ifdef HAVE_PGTK
|
||||
mark_pgtkterm ();
|
||||
|
|
|
|||
|
|
@ -2271,14 +2271,13 @@ See also `charset-priority-list' and `set-charset-priority'. */)
|
|||
}
|
||||
|
||||
/* 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);
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -321,7 +321,7 @@ get_composition_id (ptrdiff_t charpos, ptrdiff_t bytepos, ptrdiff_t nchars,
|
|||
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;
|
||||
|
|
@ -673,7 +673,7 @@ Lisp_Object
|
|||
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);
|
||||
}
|
||||
|
||||
|
|
@ -2148,6 +2148,16 @@ of the way buffer text is examined for matching one of the rules. */)
|
|||
}
|
||||
|
||||
|
||||
/* 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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -84,8 +84,7 @@ composition_registered_p (Lisp_Object prop)
|
|||
? 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'. */
|
||||
|
|
@ -163,8 +162,8 @@ 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. */
|
||||
|
|
@ -200,6 +199,7 @@ extern bool find_composition (ptrdiff_t, ptrdiff_t, ptrdiff_t *, ptrdiff_t *,
|
|||
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);
|
||||
|
||||
|
|
|
|||
|
|
@ -4073,6 +4073,7 @@ extern ptrdiff_t multibyte_chars_in_text (const unsigned char *, ptrdiff_t);
|
|||
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);
|
||||
|
|
|
|||
|
|
@ -2650,11 +2650,6 @@ hash_table_contents (struct Lisp_Hash_Table *h)
|
|||
* 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;
|
||||
|
|
|
|||
Loading…
Reference in a new issue