MimIR 0.1
MimIR is my Intermediate Representation
Loading...
Searching...
No Matches
hash.cpp
Go to the documentation of this file.
1#include "mim/util/hash.h"
2
3namespace mim {
4
5hash_t hash(const char* s) {
6 hash_t seed = mim::hash_begin();
7 for (const char* p = s; *p != '\0'; ++p) seed = mim::hash_combine(seed, *p);
8 return seed;
9}
10
11hash_t hash(std::string_view s) {
12 hash_t seed = mim::hash_begin(s.size());
13 for (auto c : s) seed = mim::hash_combine(seed, c);
14 return seed;
15}
16
17} // namespace mim
Definition cfg.h:11
hash_t hash_combine(hash_t seed, T v)
Returns a new hash by combining the hash seed with val.
Definition hash.h:82
hash_t hash_begin()
Definition hash.h:102
uint32_t hash_t
Definition hash.h:9
hash_t hash(const char *)
Definition hash.cpp:5