mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-15 10:30:25 -08:00
; Reorder struct Lisp_Hash_Table and struct hash_table_test
Mainly for efficiency, to keep frequently used fields together.
This commit is contained in:
parent
7d93a0147a
commit
47502c55b0
2 changed files with 23 additions and 24 deletions
12
src/fns.c
12
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. */
|
||||
|
||||
|
|
|
|||
35
src/lisp.h
35
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. */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue