Files
native_invoker_v2/include/fxn/utility.hpp

29 lines
613 B
C++

#pragma once
#include <string_view>
#include <cstdint>
namespace fxn
{
inline constexpr char ToLower(const char c) noexcept
{
return (c >= 'A' && c <= 'Z') ? (c - 'A' + 'a') : c;
}
inline constexpr unsigned int HashString(std::string_view str) noexcept
{
std::uint32_t hash = 0;
for (char ch : str)
{
hash += ToLower(ch);
hash += (hash << 10);
hash ^= (hash >> 6);
}
hash += (hash << 3);
hash ^= (hash >> 11);
hash += (hash << 15);
return hash;
}
}