aboutsummaryrefslogtreecommitdiff
path: root/gdb/utils.h
diff options
context:
space:
mode:
authorChristian Biesinger <cbiesinger@google.com>2019-12-02 18:58:35 -0600
committerChristian Biesinger <cbiesinger@google.com>2019-12-03 15:27:15 -0600
commit4cbd39b289b012782df2fdda9adc7eacdcfc6ad7 (patch)
treef52aba927c48c83dca2923c7c3c0c55657ca29c1 /gdb/utils.h
parent82f910ea9cce04b0faabfcd022d9d8949567541e (diff)
downloadbinutils-4cbd39b289b012782df2fdda9adc7eacdcfc6ad7.zip
binutils-4cbd39b289b012782df2fdda9adc7eacdcfc6ad7.tar.gz
binutils-4cbd39b289b012782df2fdda9adc7eacdcfc6ad7.tar.bz2
Replace hash function from bcache with fast_hash
This function is not just slower than xxhash, it is slower than even libiberty's iterative_hash, so there does not seem to be a reason for it to exist. ------------------------------------------------------------ Benchmark Time CPU Iterations ------------------------------------------------------------ BM_xxh3 11 ns 11 ns 66127192 BM_xxh32 19 ns 19 ns 36792609 BM_xxh64 16 ns 16 ns 42941328 BM_city32 26 ns 26 ns 27028370 BM_city64 17 ns 17 ns 40472793 BM_iterative_hash 77 ns 77 ns 9088854 BM_bcache_hash 125 ns 125 ns 5599232 gdb/ChangeLog: 2019-12-03 Christian Biesinger <cbiesinger@google.com> * bcache.c (hash): Remove. (hash_continue): Remove. * bcache.h (hash): Remove. (hash_continue): Remove. (struct bcache) <ctor>: Update. * psymtab.c (psymbol_hash): Update. * stabsread.c (hashname): Update. * utils.h (fast_hash): Add an argument for a start value, defaulting to zero. Change-Id: I107f013eda5fdd3293326b5a206be43155dae0f8
Diffstat (limited to 'gdb/utils.h')
-rw-r--r--gdb/utils.h11
1 files changed, 6 insertions, 5 deletions
diff --git a/gdb/utils.h b/gdb/utils.h
index 79c8a6f..c8337f2 100644
--- a/gdb/utils.h
+++ b/gdb/utils.h
@@ -571,17 +571,18 @@ extern void copy_bitwise (gdb_byte *dest, ULONGEST dest_offset,
const gdb_byte *source, ULONGEST source_offset,
ULONGEST nbits, int bits_big_endian);
-/* A fast hashing function. This can be used to hash strings in a fast way
+/* A fast hashing function. This can be used to hash data in a fast way
when the length is known. If no fast hashing library is available, falls
- back to iterative_hash from libiberty. */
+ back to iterative_hash from libiberty. START_VALUE can be set to
+ continue hashing from a previous value. */
static inline unsigned int
-fast_hash (const char* str, size_t len)
+fast_hash (const void *ptr, size_t len, unsigned int start_value = 0)
{
#ifdef HAVE_LIBXXHASH
- return XXH64 (str, len, 0);
+ return XXH64 (ptr, len, start_value);
#else
- return iterative_hash (str, len, 0);
+ return iterative_hash (ptr, len, start_value);
#endif
}