emacs-diffs
[Top][All Lists]
Advanced

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

scratch/hash-table-perf 31950946290 04/37: Refactor: less egregious laye


From: Mattias Engdegård
Subject: scratch/hash-table-perf 31950946290 04/37: Refactor: less egregious layering violation in composite.h
Date: Sun, 7 Jan 2024 12:41:04 -0500 (EST)

branch: scratch/hash-table-perf
commit 319509462904d4d480aee4535cdd35836437817e
Author: Mattias Engdegård <mattiase@acm.org>
Commit: Mattias Engdegård <mattiase@acm.org>

    Refactor: less egregious 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 0f791c1ea62..a8497ff574f 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]