]> git.eshelyaron.com Git - emacs.git/commit
Faster hash table growth, starting at zero size
authorMattias Engdegård <mattiase@acm.org>
Sat, 4 Nov 2023 17:21:06 +0000 (18:21 +0100)
committerMattias Engdegård <mattiase@acm.org>
Sat, 13 Jan 2024 19:50:38 +0000 (20:50 +0100)
commited06de52a53135ee42e528496fdddbf3d74b0479
treeee3528ede552b36163055c0fb75da21ac539dff9
parent47502c55b0ce2e4cd3f43fefb77d9c2c11ed7c0a
Faster hash table growth, starting at zero size

The algorithms no longer use the rehash_threshold and rehash_size
float constants, but vary depending on size.  In particular, the table
now grows faster, especially from smaller sizes.

The default size is now 0, starting empty, which effectively postpones
allocation until the first insertion (unless make-hash-table was
called with a positive :size); this is a clear gain as long as the
table remains empty.  The first inserted item will use an initial size
of 8 because most tables are small.

* src/fns.c (std_rehash_size, std_rehash_threshold): Remove.
(hash_index_size): Integer-only computation.
(maybe_resize_hash_table): Grow more aggressively.
(Fhash_table_rehash_size, Fhash_table_rehash_threshold):
Use the constants directly.
* src/lisp.h (DEFAULT_HASH_SIZE): New value.
src/fns.c
src/lisp.h