Skip to content

Commit

Permalink
hash: Rewrite hash table code
Browse files Browse the repository at this point in the history
This is a complete rewrite of the code in hash.c

Move from a chained hash table implementation to open addressing with
Robin Hood probing. This allows to increase the maximum fill factor and
further reduce the growth factor, saving considerable amounts of memory
without sacrificing performance.

To make this work, hash values are now cached in the table entry
also avoiding many key comparisons.

Tables are created lazily with a smaller minimum size.

Insertion functions now report an error if growing the table resulted in
a memory allocation failure.

Some string comparisons were optimized to call directly into libc
instead of using the xmlstring API.

The length of inserted keys is computed along with the hash improving
allocation performance.

Bounds checking was made more robust.

In dictionary-based mode, unneeded interning of strings is avoided.
  • Loading branch information
nwellnhof committed Sep 29, 2023
1 parent 4f221a7 commit 4a513d5
Show file tree
Hide file tree
Showing 2 changed files with 830 additions and 871 deletions.
2 changes: 1 addition & 1 deletion Copyright
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Except where otherwise noted in the source code (e.g. the files hash.c,
Except where otherwise noted in the source code (e.g. the files dict.c,
list.c and the trio files, which are covered by a similar licence but
with different Copyright notices) all the files are:

Expand Down
Loading

0 comments on commit 4a513d5

Please sign in to comment.