diff options
author | Tom Tromey <tom@tromey.com> | 2021-03-21 11:15:57 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2022-04-12 09:31:16 -0600 |
commit | 4e9e4fcda5e820d770369824669d86d3fadcad04 (patch) | |
tree | bd29e77f2f2dae6c347e2ef0e40c2fe28aba4a7c /gdb/dwarf2/index-common.c | |
parent | b2bc564fe817f857b4915903f16026472acfbdcc (diff) | |
download | binutils-4e9e4fcda5e820d770369824669d86d3fadcad04.zip binutils-4e9e4fcda5e820d770369824669d86d3fadcad04.tar.gz binutils-4e9e4fcda5e820d770369824669d86d3fadcad04.tar.bz2 |
Add new overload of dwarf5_djb_hash
This adds a new overload of dwarf5_djb_hash. This is used in
subsequent patches.
Diffstat (limited to 'gdb/dwarf2/index-common.c')
-rw-r--r-- | gdb/dwarf2/index-common.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/gdb/dwarf2/index-common.c b/gdb/dwarf2/index-common.c index c2bb1c6..d8f9973 100644 --- a/gdb/dwarf2/index-common.c +++ b/gdb/dwarf2/index-common.c @@ -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; +} |