Share hash table test structs

This saves several words in the hash table object at the cost of an
indirection at runtime.  This seems to be a gain in overall
performance.

FIXME: We cache hash test objects in a rather clumsy way. A better
solution is sought.

* src/lisp.h (struct Lisp_Hash_Table): Use a pointer to the test
struct.  All references adapted.
* src/alloc.c (garbage_collect):
* src/fns.c (struct hash_table_user_test, hash_table_user_tests)
(mark_fns, get_hash_table_user_test): New state for caching test
structs, and functions managing it.
This commit is contained in:
Mattias Engdegård
2023-11-02 17:05:26 +01:00
parent 0a998938ca
commit 7d93a0147a
15 changed files with 90 additions and 51 deletions

View File

@@ -1743,7 +1743,7 @@ exec_byte_code (Lisp_Object fun, ptrdiff_t args_template,
/* h->count is a faster approximation for HASH_TABLE_SIZE (h)
here. */
if (h->count <= 5 && !h->test.cmpfn)
if (h->count <= 5 && !h->test->cmpfn)
{ /* Do a linear search if there are not many cases
FIXME: 5 is arbitrarily chosen. */
for (i = h->count; 0 <= --i; )