Commit 721cf711 authored by Dominik Charousset's avatar Dominik Charousset

Fix unused-const-variable warning

parent b52c9432
...@@ -18,41 +18,42 @@ ...@@ -18,41 +18,42 @@
#include "caf/detail/fnv_hash.hpp" #include "caf/detail/fnv_hash.hpp"
#include <cstdint>
namespace caf { namespace caf {
namespace detail { namespace detail {
namespace { namespace {
template <size_t IntegerSize> #if SIZE_MAX == 0xFFFFFFFF
struct hash_conf_helper;
constexpr size_t basis = 2166136261u;
constexpr size_t prime = 16777619u;
#elif SIZE_MAX == 0xFFFFFFFFFFFFFFFF
template <> constexpr size_t basis = 14695981039346656037u;
struct hash_conf_helper<4> {
static constexpr size_t basis = 2166136261u;
static constexpr size_t prime = 16777619u; constexpr size_t prime = 1099511628211u;
};
template <> #else
struct hash_conf_helper<8> {
static constexpr size_t basis = 14695981039346656037u;
static constexpr size_t prime = 1099511628211u; # error Platform and/or compiler not supported
};
struct hash_conf : hash_conf_helper<sizeof(size_t)> {}; #endif
} // namespace } // namespace
size_t fnv_hash(const unsigned char* first, const unsigned char* last) { size_t fnv_hash(const unsigned char* first, const unsigned char* last) {
return fnv_hash_append(hash_conf::basis, first, last); return fnv_hash_append(basis, first, last);
} }
size_t fnv_hash_append(size_t intermediate, const unsigned char* first, size_t fnv_hash_append(size_t intermediate, const unsigned char* first,
const unsigned char* last) { const unsigned char* last) {
auto result = intermediate; auto result = intermediate;
for (; first != last; ++first) { for (; first != last; ++first) {
result *= hash_conf::prime; result *= prime;
result ^= *first; result ^= *first;
} }
return result; return result;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment