aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/symtab.c2
-rw-r--r--gdbsupport/common-utils.h17
2 files changed, 18 insertions, 1 deletions
diff --git a/gdb/symtab.c b/gdb/symtab.c
index f2b1a14..b344513 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -812,7 +812,7 @@ hash_demangled_name_entry (const void *data)
const struct demangled_name_entry *e
= (const struct demangled_name_entry *) data;
- return fast_hash (e->mangled.data (), e->mangled.length ());
+ return gdb::string_view_hash () (e->mangled);
}
/* Equality function for the demangled name hash. */
diff --git a/gdbsupport/common-utils.h b/gdbsupport/common-utils.h
index 31ab1a6..97dcb9f 100644
--- a/gdbsupport/common-utils.h
+++ b/gdbsupport/common-utils.h
@@ -209,4 +209,21 @@ fast_hash (const void *ptr, size_t len, unsigned int start_value = 0)
#endif
}
+namespace gdb
+{
+
+/* Hash type for gdb::string_view.
+
+ Even after we switch to C++17 and dump our string_view implementation, we
+ might want to keep this hash implementation if it's faster than std::hash
+ for std::string_view. */
+
+struct string_view_hash
+{
+ std::size_t operator() (gdb::string_view view) const
+ { return fast_hash (view.data (), view.length ()); }
+};
+
+} /* namespace gdb */
+
#endif /* COMMON_COMMON_UTILS_H */