]> 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)
committerEshel Yaron <me@eshelyaron.com>
Sun, 14 Jan 2024 15:15:44 +0000 (16:15 +0100)
commit14622b2d4ba7b13326305eff68080a2a34d3e5eb
tree4e7a7045835aa4592ef231c35437b73496a6443c
parent3d2163db1edac2317902c98bfc6dd15ad29eaee4
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.

(cherry picked from commit ed06de52a53135ee42e528496fdddbf3d74b0479)
src/fns.c
src/lisp.h