emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 3da324fbd3c 04/11: Refactor: less layering violation in composite


From: Mattias Engdegård
Subject: master 3da324fbd3c 04/11: Refactor: less layering violation in composite.h
Date: Fri, 12 Jan 2024 12:04:45 -0500 (EST)

branch: master
commit 3da324fbd3c7e8e282585ed617efe6ae740acf1a
Author: Mattias Engdegård <mattiase@acm.org>
Commit: Mattias Engdegård <mattiase@acm.org>

    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;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]