aboutsummaryrefslogtreecommitdiff
path: root/include/FnvHash.hpp
blob: 776675631f425dd2ee555f6f68ff81b01cacc515 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#pragma once

#include "types.hpp"

namespace sibs
{
    // Source: https://stackoverflow.com/a/11414104 (public license)
    static usize fnvHash(const unsigned char *key, int len)
    {
        usize h = 2166136261ULL;
        for (int i = 0; i < len; i++)
            h = (h * 16777619ULL) ^ key[i];
        return h;
    }
}