aboutsummaryrefslogtreecommitdiffstats
path: root/util/generic/string_hash.h
blob: b873f23b11bc4bcb08907d37ab3c168afe4842fe (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#pragma once

#include <cstddef>

// reduce code bloat and cycled includes, declare functions here
#if defined(_64_) && !defined(NO_CITYHASH)
ui64 CityHash64(const char* buf, size_t len) noexcept;
#else
template <typename T>
T MurmurHash(const void* buf, size_t len) noexcept;
#endif

namespace NHashPrivate {
    template <typename C>
    size_t ComputeStringHash(const C* ptr, size_t size) noexcept {
#if defined(_64_) && !defined(NO_CITYHASH)
        return CityHash64((const char*)ptr, size * sizeof(C));
#else
        return MurmurHash<size_t>(ptr, size * sizeof(C));
#endif
    }
}