refactor: Unify string hashing
> moved to util/utils.h
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user