diff options
author | dec05eba <0xdec05eba@gmail.com> | 2018-10-16 00:37:21 +0200 |
---|---|---|
committer | dec05eba <0xdec05eba@gmail.com> | 2018-10-16 00:37:25 +0200 |
commit | eda94456add9a65d1821302e343bef4021d2a773 (patch) | |
tree | 237e09b79c0e8b853b0892deca8b67713a8c4634 /include/FnvHash.hpp | |
parent | 29d93a061a8fcc36e5d7afd1dbcd0a6fefbbabaa (diff) |
Reuse peer connection if subscribed to same key
Diffstat (limited to 'include/FnvHash.hpp')
-rw-r--r-- | include/FnvHash.hpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/include/FnvHash.hpp b/include/FnvHash.hpp new file mode 100644 index 0000000..7766756 --- /dev/null +++ b/include/FnvHash.hpp @@ -0,0 +1,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; + } +}
\ No newline at end of file |