]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
gdbsupport: add unordered_dense.h 4.4.0
authorSimon Marchi <simon.marchi@efficios.com>
Mon, 4 Nov 2024 18:27:35 +0000 (13:27 -0500)
committerSimon Marchi <simon.marchi@polymtl.ca>
Tue, 26 Nov 2024 03:07:03 +0000 (22:07 -0500)
commit8f942ca8a5259e8dac4745df1b15b80467346a0d
tree6a080bcfb77345b7fc2735c1fdaca769329509e4
parent27f442142746e91af5aa4a6fb6d77de567557216
gdbsupport: add unordered_dense.h 4.4.0

Add a copy of unordered_dense.h from [1].  This file implements an
efficient hash map and hash set with a nice C++ interface (a near
drop-in for std::unordered_map and std::unordered_set).  This is
expected to be used to replace uses of `htab_t`, for improved code
readability and type safety.  Performance-wise, it is preferred to the
std types (std::unordered_map and std::unordered_set) due to it using
open addressing vs closed addressing for the std types.

I chose this particular implementation because it is simple to use, it's
a standalone header and it typically performs well in benchmarks I have
seen (e.g. [2]).  The license being MIT, my understanding is that it's
not a problem to use it and re-distribute it.

Add two additional files, gdbsupport/unordered_map.h and
gdbsupport/unordered_set.h, which make the map and set offered by
gdbsupport/unordered_dense.h available as gdb::unordered_map and
gdb::unordered_set.

[1] https://github.com/martinus/unordered_dense
[2] https://jacksonallan.github.io/c_cpp_hash_tables_benchmark/#conclusion-which-hash-table-to-choose

Change-Id: I0c7469ccf9a14540465479e58b2a5140a2440a7d
Approved-By: Tom Tromey <tom@tromey.com>
gdbsupport/unordered_dense.h [new file with mode: 0644]
gdbsupport/unordered_map.h [new file with mode: 0644]
gdbsupport/unordered_set.h [new file with mode: 0644]