From 3da324fbd3c7e8e282585ed617efe6ae740acf1a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Mattias=20Engdeg=C3=A5rd?= Date: Mon, 30 Oct 2023 12:34:26 +0100 Subject: [PATCH] Refactor: less layering violation in composite.h Avoid using hash table internals directly. * src/composite.h (COMPOSITION_KEY): New. (COMPOSITION_GLYPH, COMPOSITION_RULE): Use COMPOSITION_KEY. --- src/composite.h | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/composite.h b/src/composite.h index c99888ccec2..4fe49b764e4 100644 --- a/src/composite.h +++ b/src/composite.h @@ -84,23 +84,21 @@ 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) + /* Return the Nth glyph of composition specified by CMP. CMP is a pointer to `struct composition'. */ #define COMPOSITION_GLYPH(cmp, n) \ - XFIXNUM (XVECTOR (XVECTOR (XHASH_TABLE (composition_hash_table) \ - ->key_and_value) \ - ->contents[cmp->hash_index * 2]) \ - ->contents[cmp->method == COMPOSITION_WITH_RULE_ALTCHARS \ - ? (n) * 2 : (n)]) + XFIXNUM (AREF (COMPOSITION_KEY (cmp), \ + (cmp)->method == COMPOSITION_WITH_RULE_ALTCHARS \ + ? (n) * 2 : (n))) /* Return the encoded composition rule to compose the Nth glyph of rule-base composition specified by CMP. CMP is a pointer to `struct composition'. */ -#define COMPOSITION_RULE(cmp, n) \ - XFIXNUM (XVECTOR (XVECTOR (XHASH_TABLE (composition_hash_table) \ - ->key_and_value) \ - ->contents[cmp->hash_index * 2]) \ - ->contents[(n) * 2 - 1]) +#define COMPOSITION_RULE(cmp, n) \ + XFIXNUM (AREF (COMPOSITION_KEY (cmp), (n) * 2 - 1)) /* Decode encoded composition rule RULE_CODE into GREF (global reference point code), NREF (new ref. point code). Don't check RULE_CODE; -- 2.39.2