Add new overload of dwarf5_djb_hash

This adds a new overload of dwarf5_djb_hash.  This is used in
subsequent patches.
This commit is contained in:
Tom Tromey
2021-03-21 11:15:57 -06:00
parent b2bc564fe8
commit 4e9e4fcda5
2 changed files with 18 additions and 0 deletions

View File

@@ -54,3 +54,17 @@ dwarf5_djb_hash (const char *str_)
hash = hash * 33 + tolower (c);
return hash;
}
/* See dwarf-index-common.h. */
uint32_t
dwarf5_djb_hash (gdb::string_view str)
{
/* Note: tolower here ignores UTF-8, which isn't fully compliant.
See http://dwarfstd.org/ShowIssue.php?issue=161027.1. */
uint32_t hash = 5381;
for (char c : str)
hash = hash * 33 + tolower (c & 0xff);
return hash;
}

View File

@@ -52,4 +52,8 @@ hashval_t mapped_index_string_hash (int index_version, const void *p);
uint32_t dwarf5_djb_hash (const char *str_);
/* Symbol name hashing function as specified by DWARF-5. */
uint32_t dwarf5_djb_hash (gdb::string_view str_);
#endif /* DWARF_INDEX_COMMON_H */