[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 47502c55b0c 13/20: ; Reorder struct Lisp_Hash_Table and struct ha
From: |
Mattias Engdegård |
Subject: |
master 47502c55b0c 13/20: ; Reorder struct Lisp_Hash_Table and struct hash_table_test |
Date: |
Sat, 13 Jan 2024 14:54:02 -0500 (EST) |
branch: master
commit 47502c55b0ce2e4cd3f43fefb77d9c2c11ed7c0a
Author: Mattias Engdegård <mattiase@acm.org>
Commit: Mattias Engdegård <mattiase@acm.org>
; Reorder struct Lisp_Hash_Table and struct hash_table_test
Mainly for efficiency, to keep frequently used fields together.
---
src/fns.c | 12 ++++++------
src/lisp.h | 35 +++++++++++++++++------------------
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)
}
struct hash_table_test const
- hashtest_eq = { LISPSYM_INITIALLY (Qeq), LISPSYM_INITIALLY (Qnil),
- LISPSYM_INITIALLY (Qnil), 0, hashfn_eq },
- hashtest_eql = { LISPSYM_INITIALLY (Qeql), LISPSYM_INITIALLY (Qnil),
- LISPSYM_INITIALLY (Qnil), cmpfn_eql, hashfn_eql },
- hashtest_equal = { LISPSYM_INITIALLY (Qequal), LISPSYM_INITIALLY (Qnil),
- LISPSYM_INITIALLY (Qnil), cmpfn_equal, hashfn_equal };
+ hashtest_eq = { .name = LISPSYM_INITIALLY (Qeq),
+ .cmpfn = 0, .hashfn = hashfn_eq },
+ hashtest_eql = { .name = LISPSYM_INITIALLY (Qeql),
+ .cmpfn = cmpfn_eql, .hashfn = hashfn_eql },
+ hashtest_equal = { .name = LISPSYM_INITIALLY (Qequal),
+ .cmpfn = cmpfn_equal, .hashfn = hashfn_equal };
/* Allocate basically initialized hash table. */
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 {
struct hash_table_test
{
- /* FIXME: reorder for efficiency */
- /* Function used to compare keys; always a bare symbol. */
- Lisp_Object name;
+ /* C function to compute hash code. */
+ hash_hash_t (*hashfn) (Lisp_Object, struct Lisp_Hash_Table *);
+
+ /* C function to compare two keys. */
+ Lisp_Object (*cmpfn) (Lisp_Object, Lisp_Object, struct Lisp_Hash_Table *);
/* User-supplied hash function, or nil. */
Lisp_Object user_hash_function;
@@ -2407,11 +2409,8 @@ struct hash_table_test
/* User-supplied key comparison function, or nil. */
Lisp_Object user_cmp_function;
- /* C function to compare two keys. */
- Lisp_Object (*cmpfn) (Lisp_Object, Lisp_Object, struct Lisp_Hash_Table *);
-
- /* C function to compute hash code. */
- hash_hash_t (*hashfn) (Lisp_Object, struct Lisp_Hash_Table *);
+ /* Function used to compare keys; always a bare symbol. */
+ Lisp_Object name;
};
typedef enum {
@@ -2480,6 +2479,16 @@ struct Lisp_Hash_Table
This vector is table_size entries long. */
hash_hash_t *hash;
+ /* Vector of keys and values. The key of item I is found at index
+ 2 * I, the value is found at index 2 * I + 1.
+ If the key is HASH_UNUSED_ENTRY_KEY, then this slot is unused.
+ This is gc_marked specially if the table is weak.
+ This vector is 2 * table_size entries long. */
+ Lisp_Object *key_and_value;
+
+ /* The comparison and hash functions. */
+ const struct hash_table_test *test;
+
/* Vector used to chain entries. If entry I is free, next[I] is the
entry number of the next free item. If entry I is non-free,
next[I] is the index of the next entry in the collision chain,
@@ -2508,16 +2517,6 @@ struct Lisp_Hash_Table
immutable for recursive attempts to mutate it. */
bool mutable;
- /* Vector of keys and values. The key of item I is found at index
- 2 * I, the value is found at index 2 * I + 1.
- If the key is HASH_UNUSED_ENTRY_KEY, then this slot is unused.
- This is gc_marked specially if the table is weak.
- This vector is 2 * table_size entries long. */
- Lisp_Object *key_and_value;
-
- /* The comparison and hash functions. */
- const struct hash_table_test *test;
-
/* Next weak hash table if this is a weak hash table. The head of
the list is in weak_hash_tables. Used only during garbage
collection --- at other times, it is NULL. */
- master fa5c07fc87d 08/20: Use non-Lisp allocation for internal hash-table vectors, (continued)
- master fa5c07fc87d 08/20: Use non-Lisp allocation for internal hash-table vectors, Mattias Engdegård, 2024/01/13
- master 7ad5d427730 16/20: Don't dump Qunbound, Mattias Engdegård, 2024/01/13
- master d2c3a983146 20/20: Hash-table documentation updates (bug#68244), Mattias Engdegård, 2024/01/13
- master a09619f2598 02/20: * src/print.c (print_object): Don't print empty hash-table data, Mattias Engdegård, 2024/01/13
- master 3f9c81a87f7 03/20: Don't print or read the hash table size parameter, Mattias Engdegård, 2024/01/13
- master d3cefd3e983 06/20: Leaner hash table dumping and thawing, Mattias Engdegård, 2024/01/13
- master 519c7ca7356 19/20: Don't pretend that hash-table-size is useful, Mattias Engdegård, 2024/01/13
- master 3b00255a4c7 10/20: Inlined and specialised hash table look-up, Mattias Engdegård, 2024/01/13
- master 1998039f7a8 18/20: Change hash_hash_t to uint32_t, Mattias Engdegård, 2024/01/13
- master 7d93a0147a1 12/20: Share hash table test structs, Mattias Engdegård, 2024/01/13
- master 47502c55b0c 13/20: ; Reorder struct Lisp_Hash_Table and struct hash_table_test,
Mattias Engdegård <=
- master c6bdc1ea1dc 04/20: Represent hash table weakness as an enum internally, Mattias Engdegård, 2024/01/13
- master 68f8bc31114 15/20: Change hash_idx_t to int32_t on all platforms, Mattias Engdegård, 2024/01/13
- master 0a998938ca1 11/20: Use hash_idx_t for storing hash indices, Mattias Engdegård, 2024/01/13
- master 11e467eb600 17/20: Use key Qunbound instead of hash value hash_unused for free entries, Mattias Engdegård, 2024/01/13