aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMattias EngdegÄrd2023-11-03 16:02:56 +0100
committerMattias EngdegÄrd2024-01-13 20:50:38 +0100
commit47502c55b0ce2e4cd3f43fefb77d9c2c11ed7c0a (patch)
treec3f841c4d8dd5c3ec0801ffe4870b06c302e24e0 /src
parent7d93a0147a14e14d6964bf93ba11cf494b9d49fd (diff)
downloademacs-47502c55b0ce2e4cd3f43fefb77d9c2c11ed7c0a.tar.gz
emacs-47502c55b0ce2e4cd3f43fefb77d9c2c11ed7c0a.zip
; Reorder struct Lisp_Hash_Table and struct hash_table_test
Mainly for efficiency, to keep frequently used fields together.
Diffstat (limited to 'src')
-rw-r--r--src/fns.c12
-rw-r--r--src/lisp.h35
2 files changed, 23 insertions, 24 deletions
diff --git a/src/fns.c b/src/fns.c
index e491202cf54..3e650b13c1f 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -4493,12 +4493,12 @@ hashfn_user_defined (Lisp_Object key, struct Lisp_Hash_Table *h)
4493} 4493}
4494 4494
4495struct hash_table_test const 4495struct hash_table_test const
4496 hashtest_eq = { LISPSYM_INITIALLY (Qeq), LISPSYM_INITIALLY (Qnil), 4496 hashtest_eq = { .name = LISPSYM_INITIALLY (Qeq),
4497 LISPSYM_INITIALLY (Qnil), 0, hashfn_eq }, 4497 .cmpfn = 0, .hashfn = hashfn_eq },
4498 hashtest_eql = { LISPSYM_INITIALLY (Qeql), LISPSYM_INITIALLY (Qnil), 4498 hashtest_eql = { .name = LISPSYM_INITIALLY (Qeql),
4499 LISPSYM_INITIALLY (Qnil), cmpfn_eql, hashfn_eql }, 4499 .cmpfn = cmpfn_eql, .hashfn = hashfn_eql },
4500 hashtest_equal = { LISPSYM_INITIALLY (Qequal), LISPSYM_INITIALLY (Qnil), 4500 hashtest_equal = { .name = LISPSYM_INITIALLY (Qequal),
4501 LISPSYM_INITIALLY (Qnil), cmpfn_equal, hashfn_equal }; 4501 .cmpfn = cmpfn_equal, .hashfn = hashfn_equal };
4502 4502
4503/* Allocate basically initialized hash table. */ 4503/* Allocate basically initialized hash table. */
4504 4504
diff --git a/src/lisp.h b/src/lisp.h
index b11237381d9..658bcd8b780 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -2397,9 +2397,11 @@ typedef enum {
2397 2397
2398struct hash_table_test 2398struct hash_table_test
2399{ 2399{
2400 /* FIXME: reorder for efficiency */ 2400 /* C function to compute hash code. */
2401 /* Function used to compare keys; always a bare symbol. */ 2401 hash_hash_t (*hashfn) (Lisp_Object, struct Lisp_Hash_Table *);
2402 Lisp_Object name; 2402
2403 /* C function to compare two keys. */
2404 Lisp_Object (*cmpfn) (Lisp_Object, Lisp_Object, struct Lisp_Hash_Table *);
2403 2405
2404 /* User-supplied hash function, or nil. */ 2406 /* User-supplied hash function, or nil. */
2405 Lisp_Object user_hash_function; 2407 Lisp_Object user_hash_function;
@@ -2407,11 +2409,8 @@ struct hash_table_test
2407 /* User-supplied key comparison function, or nil. */ 2409 /* User-supplied key comparison function, or nil. */
2408 Lisp_Object user_cmp_function; 2410 Lisp_Object user_cmp_function;
2409 2411
2410 /* C function to compare two keys. */ 2412 /* Function used to compare keys; always a bare symbol. */
2411 Lisp_Object (*cmpfn) (Lisp_Object, Lisp_Object, struct Lisp_Hash_Table *); 2413 Lisp_Object name;
2412
2413 /* C function to compute hash code. */
2414 hash_hash_t (*hashfn) (Lisp_Object, struct Lisp_Hash_Table *);
2415}; 2414};
2416 2415
2417typedef enum { 2416typedef enum {
@@ -2480,6 +2479,16 @@ struct Lisp_Hash_Table
2480 This vector is table_size entries long. */ 2479 This vector is table_size entries long. */
2481 hash_hash_t *hash; 2480 hash_hash_t *hash;
2482 2481
2482 /* Vector of keys and values. The key of item I is found at index
2483 2 * I, the value is found at index 2 * I + 1.
2484 If the key is HASH_UNUSED_ENTRY_KEY, then this slot is unused.
2485 This is gc_marked specially if the table is weak.
2486 This vector is 2 * table_size entries long. */
2487 Lisp_Object *key_and_value;
2488
2489 /* The comparison and hash functions. */
2490 const struct hash_table_test *test;
2491
2483 /* Vector used to chain entries. If entry I is free, next[I] is the 2492 /* Vector used to chain entries. If entry I is free, next[I] is the
2484 entry number of the next free item. If entry I is non-free, 2493 entry number of the next free item. If entry I is non-free,
2485 next[I] is the index of the next entry in the collision chain, 2494 next[I] is the index of the next entry in the collision chain,
@@ -2508,16 +2517,6 @@ struct Lisp_Hash_Table
2508 immutable for recursive attempts to mutate it. */ 2517 immutable for recursive attempts to mutate it. */
2509 bool mutable; 2518 bool mutable;
2510 2519
2511 /* Vector of keys and values. The key of item I is found at index
2512 2 * I, the value is found at index 2 * I + 1.
2513 If the key is HASH_UNUSED_ENTRY_KEY, then this slot is unused.
2514 This is gc_marked specially if the table is weak.
2515 This vector is 2 * table_size entries long. */
2516 Lisp_Object *key_and_value;
2517
2518 /* The comparison and hash functions. */
2519 const struct hash_table_test *test;
2520
2521 /* Next weak hash table if this is a weak hash table. The head of 2520 /* Next weak hash table if this is a weak hash table. The head of
2522 the list is in weak_hash_tables. Used only during garbage 2521 the list is in weak_hash_tables. Used only during garbage
2523 collection --- at other times, it is NULL. */ 2522 collection --- at other times, it is NULL. */