forked from Imagelibrary/binutils-gdb
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
This commit is contained in:
25
gdb/bcache.c
25
gdb/bcache.c
@@ -51,31 +51,6 @@ struct bstring
|
||||
d;
|
||||
};
|
||||
|
||||
/* The old hash function was stolen from SDBM. This is what DB 3.0
|
||||
uses now, and is better than the old one. */
|
||||
|
||||
unsigned long
|
||||
hash(const void *addr, int length)
|
||||
{
|
||||
return hash_continue (addr, length, 0);
|
||||
}
|
||||
|
||||
/* Continue the calculation of the hash H at the given address. */
|
||||
|
||||
unsigned long
|
||||
hash_continue (const void *addr, int length, unsigned long h)
|
||||
{
|
||||
const unsigned char *k, *e;
|
||||
|
||||
k = (const unsigned char *)addr;
|
||||
e = k+length;
|
||||
for (; k< e;++k)
|
||||
{
|
||||
h *=16777619;
|
||||
h ^= *k;
|
||||
}
|
||||
return (h);
|
||||
}
|
||||
|
||||
/* Growing the bcache's hash table. */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user