From 8ec0e030b661ae50d1aef4723b4e83a03645e4ee Mon Sep 17 00:00:00 2001 From: Mattias EngdegÄrd Date: Wed, 10 Jan 2024 11:50:19 +0100 Subject: Combine hash and next vector into a single array This shrinks the hash object by one word and should give better locality since these values are often accessed at the same time. --- src/alloc.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'src/alloc.c') diff --git a/src/alloc.c b/src/alloc.c index 180b9995993..7f7e04415b4 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -3473,11 +3473,9 @@ cleanup_vector (struct Lisp_Vector *vector) eassert (h->index_size > 1); xfree (h->index); xfree (h->key_and_value); - xfree (h->next); - xfree (h->hash); + xfree (h->hash_next); ptrdiff_t bytes = (h->table_size * (2 * sizeof *h->key_and_value - + sizeof *h->hash - + sizeof *h->next) + + sizeof *h->hash_next) + h->index_size * sizeof *h->index); hash_table_allocated_bytes -= bytes; } @@ -5974,13 +5972,9 @@ purecopy_hash_table (struct Lisp_Hash_Table *table) if (table->table_size > 0) { - ptrdiff_t hash_bytes = table->table_size * sizeof *table->hash; - pure->hash = pure_alloc (hash_bytes, -(int)sizeof *table->hash); - memcpy (pure->hash, table->hash, hash_bytes); - - ptrdiff_t next_bytes = table->table_size * sizeof *table->next; - pure->next = pure_alloc (next_bytes, -(int)sizeof *table->next); - memcpy (pure->next, table->next, next_bytes); + ptrdiff_t hn_bytes = table->table_size * sizeof *table->hash_next; + pure->hash_next = pure_alloc (hn_bytes, -(int)sizeof *table->hash_next); + memcpy (pure->hash_next, table->hash_next, hn_bytes); ptrdiff_t nvalues = table->table_size * 2; ptrdiff_t kv_bytes = nvalues * sizeof *table->key_and_value; -- cgit v1.2.1