refactor: Unify string hashing

> moved to util/utils.h
This commit is contained in:
[ ]
2025-12-15 23:53:18 +09:00
parent 42689377e6
commit 7f63b77ab3
4 changed files with 32 additions and 36 deletions
+5
View File
@@ -27,6 +27,11 @@ static const char HEX_LOOKUP_UPPERCASE[16] = {
const char *inet_ntop(short af, const void *src, char *dst, DWORD size);
static inline constexpr unsigned int to_hash(const char *str, int h = 0)
{
return !str[h] ? 5381 : (to_hash(str, h + 1) * 33) ^ str[h];
}
static inline bool string_begins_with(const std::string &s, const std::string &prefix) {
return s.compare(0, prefix.size(), prefix) == 0;
}