aboutsummaryrefslogtreecommitdiff
path: root/gdb/utils.h
diff options
context:
space:
mode:
authorChristian Biesinger <cbiesinger@google.com>2019-09-27 13:08:25 -0500
committerChristian Biesinger <cbiesinger@google.com>2019-10-22 11:26:17 -0500
commit1a6ff1a96b302283d517b3cdeae7310adecbe859 (patch)
tree0865c6916b3f41de3c77f11505cef808501150cd /gdb/utils.h
parent7bb43059820c5febb4509b15202a93efde442bc6 (diff)
downloadbinutils-1a6ff1a96b302283d517b3cdeae7310adecbe859.zip
binutils-1a6ff1a96b302283d517b3cdeae7310adecbe859.tar.gz
binutils-1a6ff1a96b302283d517b3cdeae7310adecbe859.tar.bz2
Add a fast_hash function in common-utils
Also updates a caller in symtab.c. For now this just calls htab_hash_string but the next patch will change it to xxhash, if available. gdb/ChangeLog: 2019-10-22 Christian Biesinger <cbiesinger@google.com> * utils.h (fast_hash): New function. * symtab.c (hash_demangled_name_entry): Call new function fast_hash. Change-Id: I77cac0d9aa78fc65316a2af449f52edcae72dc9b
Diffstat (limited to 'gdb/utils.h')
-rw-r--r--gdb/utils.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/gdb/utils.h b/gdb/utils.h
index af8b461..478c485 100644
--- a/gdb/utils.h
+++ b/gdb/utils.h
@@ -567,4 +567,14 @@ 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
+ when the length is known. If no fast hashing library is available, falls
+ back to iterative_hash from libiberty. */
+
+static inline unsigned int
+fast_hash (const char* str, size_t len)
+{
+ return iterative_hash (str, len, 0);
+}
+
#endif /* UTILS_H */