[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
scratch/hash-table-perf 589318470c1 24/35: ; Reorder structs (hash and t
From: |
Mattias Engdegård |
Subject: |
scratch/hash-table-perf 589318470c1 24/35: ; Reorder structs (hash and test) |
Date: |
Fri, 12 Jan 2024 10:53:26 -0500 (EST) |
branch: scratch/hash-table-perf
commit 589318470c14af1382694ba1d8aa8e026cb954e7
Author: Mattias Engdegård <mattiase@acm.org>
Commit: Mattias Engdegård <mattiase@acm.org>
; Reorder structs (hash and 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 296ed3628fb..0bb508db7cb 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 48ab6142b0f..d7501e3bd37 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 {
@@ -2477,6 +2476,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,
@@ -2505,16 +2514,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. */
- scratch/hash-table-perf e55fcdafa07 09/35: Abstract predicate and constant for unused hash keys, (continued)
- scratch/hash-table-perf e55fcdafa07 09/35: Abstract predicate and constant for unused hash keys, Mattias Engdegård, 2024/01/12
- scratch/hash-table-perf 594152bf667 01/35: Add internal hash-table debug functions, Mattias Engdegård, 2024/01/12
- scratch/hash-table-perf 422c91a822a 02/35: ; * src/pdumper.c (dump_hash_table): Remove unused argument., Mattias Engdegård, 2024/01/12
- scratch/hash-table-perf f2d6e2713c0 07/35: Refactor hash table vector reallocation, Mattias Engdegård, 2024/01/12
- scratch/hash-table-perf dd4ee2c634b 15/35: Represent hash table weakness as an enum internally, Mattias Engdegård, 2024/01/12
- scratch/hash-table-perf 615d3e4cdc6 17/35: Leaner hash table dumping and thawing, Mattias Engdegård, 2024/01/12
- scratch/hash-table-perf d003b84c484 19/35: Use non-Lisp allocation for internal hash-table vectors, Mattias Engdegård, 2024/01/12
- scratch/hash-table-perf afd2185bfdb 20/35: Store hash values as integers instead of Lisp_Object, Mattias Engdegård, 2024/01/12
- scratch/hash-table-perf c98ba3d4fa6 21/35: Inlined and specialised hash table look-up, Mattias Engdegård, 2024/01/12
- scratch/hash-table-perf 414470d1e24 23/35: Share hash table test structs, Mattias Engdegård, 2024/01/12
- scratch/hash-table-perf 589318470c1 24/35: ; Reorder structs (hash and test),
Mattias Engdegård <=
- scratch/hash-table-perf bf1f1c5a9a4 25/35: Faster hash table growth, starting smaller, Mattias Engdegård, 2024/01/12
- scratch/hash-table-perf 8811c5d81e7 27/35: Don't dump Qunbound, Mattias Engdegård, 2024/01/12
- scratch/hash-table-perf ef0323e9029 30/35: Adapt hash functions to produce a hash_hash_t eventually, Mattias Engdegård, 2024/01/12
- scratch/hash-table-perf c805d2173f8 33/35: Use a static index vector for zero-sized tables, Mattias Engdegård, 2024/01/12
- scratch/hash-table-perf 8884720dce8 34/35: Change default hash table size to 0, Mattias Engdegård, 2024/01/12