diff options
| author | Mattias EngdegÄrd | 2024-01-10 11:50:19 +0100 |
|---|---|---|
| committer | Mattias EngdegÄrd | 2024-01-12 15:06:14 +0100 |
| commit | 8ec0e030b661ae50d1aef4723b4e83a03645e4ee (patch) | |
| tree | 013ed1d65639596d06143173991250fc4a0e3af6 /src/alloc.c | |
| parent | 8884720dce883142965a958fc5a33071388ec2e1 (diff) | |
| download | emacs-scratch/hash-table-perf.tar.gz emacs-scratch/hash-table-perf.zip | |
Combine hash and next vector into a single arrayscratch/hash-table-perf
This shrinks the hash object by one word and should give better
locality since these values are often accessed at the same time.
Diffstat (limited to 'src/alloc.c')
| -rw-r--r-- | src/alloc.c | 16 |
1 files changed, 5 insertions, 11 deletions
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) | |||
| 3473 | eassert (h->index_size > 1); | 3473 | eassert (h->index_size > 1); |
| 3474 | xfree (h->index); | 3474 | xfree (h->index); |
| 3475 | xfree (h->key_and_value); | 3475 | xfree (h->key_and_value); |
| 3476 | xfree (h->next); | 3476 | xfree (h->hash_next); |
| 3477 | xfree (h->hash); | ||
| 3478 | ptrdiff_t bytes = (h->table_size * (2 * sizeof *h->key_and_value | 3477 | ptrdiff_t bytes = (h->table_size * (2 * sizeof *h->key_and_value |
| 3479 | + sizeof *h->hash | 3478 | + sizeof *h->hash_next) |
| 3480 | + sizeof *h->next) | ||
| 3481 | + h->index_size * sizeof *h->index); | 3479 | + h->index_size * sizeof *h->index); |
| 3482 | hash_table_allocated_bytes -= bytes; | 3480 | hash_table_allocated_bytes -= bytes; |
| 3483 | } | 3481 | } |
| @@ -5974,13 +5972,9 @@ purecopy_hash_table (struct Lisp_Hash_Table *table) | |||
| 5974 | 5972 | ||
| 5975 | if (table->table_size > 0) | 5973 | if (table->table_size > 0) |
| 5976 | { | 5974 | { |
| 5977 | ptrdiff_t hash_bytes = table->table_size * sizeof *table->hash; | 5975 | ptrdiff_t hn_bytes = table->table_size * sizeof *table->hash_next; |
| 5978 | pure->hash = pure_alloc (hash_bytes, -(int)sizeof *table->hash); | 5976 | pure->hash_next = pure_alloc (hn_bytes, -(int)sizeof *table->hash_next); |
| 5979 | memcpy (pure->hash, table->hash, hash_bytes); | 5977 | memcpy (pure->hash_next, table->hash_next, hn_bytes); |
| 5980 | |||
| 5981 | ptrdiff_t next_bytes = table->table_size * sizeof *table->next; | ||
| 5982 | pure->next = pure_alloc (next_bytes, -(int)sizeof *table->next); | ||
| 5983 | memcpy (pure->next, table->next, next_bytes); | ||
| 5984 | 5978 | ||
| 5985 | ptrdiff_t nvalues = table->table_size * 2; | 5979 | ptrdiff_t nvalues = table->table_size * 2; |
| 5986 | ptrdiff_t kv_bytes = nvalues * sizeof *table->key_and_value; | 5980 | ptrdiff_t kv_bytes = nvalues * sizeof *table->key_and_value; |