Skip to content

Commit

Permalink
Revert "mark murmur_hash functions constexpr"
Browse files Browse the repository at this point in the history
This reverts commit 94286be.
  • Loading branch information
apolyakov committed Feb 25, 2025
1 parent 4f4235e commit 609c311
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion common/algorithms/hashes.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
namespace vk {

template<typename T>
constexpr T murmur_hash(const void *ptr, size_t len, size_t seed = static_cast<size_t>(0xc70f6907UL)) noexcept;
T murmur_hash(const void *ptr, size_t len, size_t seed = static_cast<size_t>(0xc70f6907UL)) noexcept;

inline void hash_combine(size_t &seed, size_t new_hash) {
const uint64_t m = 0xc6a4a7935bd1e995;
Expand Down
12 changes: 6 additions & 6 deletions common/algorithms/murmur-hash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@

namespace {

constexpr size_t unaligned_load(const char *p) noexcept {
size_t unaligned_load(const char *p) noexcept {
size_t result = 0;
__builtin_memcpy(&result, p, sizeof(result));
return result;
}

// Loads n bytes, where 1 <= n < 8.
constexpr size_t load_bytes(const char *p, int n) noexcept {
size_t load_bytes(const char *p, int n) noexcept {
size_t result = 0;
--n;
do {
Expand All @@ -38,7 +38,7 @@ constexpr size_t load_bytes(const char *p, int n) noexcept {
return result;
}

constexpr size_t shift_mix(size_t v) noexcept {
size_t shift_mix(size_t v) noexcept {
return v ^ (v >> 47);
}

Expand All @@ -48,8 +48,8 @@ namespace vk {

// MurMur hash function was taken from libstdc++
template<>
constexpr uint64_t murmur_hash<uint64_t>(const void *ptr, size_t len, size_t seed) noexcept {
constexpr size_t mul = (static_cast<size_t>(0xc6a4a793UL) << 32UL) + static_cast<size_t>(0x5bd1e995UL);
uint64_t murmur_hash<uint64_t>(const void *ptr, size_t len, size_t seed) noexcept {
static constexpr size_t mul = (static_cast<size_t>(0xc6a4a793UL) << 32UL) + static_cast<size_t>(0x5bd1e995UL);
const char *const buf = static_cast<const char *>(ptr);
// Remove the bytes not divisible by the sizeof(size_t). This
// allows the main loop to process the data as 64-bit integers.
Expand All @@ -72,7 +72,7 @@ constexpr uint64_t murmur_hash<uint64_t>(const void *ptr, size_t len, size_t see
}

template<>
constexpr uint32_t murmur_hash<uint32_t>(const void *ptr, size_t len, size_t seed) noexcept {
uint32_t murmur_hash<uint32_t>(const void *ptr, size_t len, size_t seed) noexcept {
uint64_t res = murmur_hash<uint64_t>(ptr, len, seed);
uint64_t mask = (1UL << 32UL) - 1;
auto head = static_cast<uint32_t>(res & mask);
Expand Down

0 comments on commit 609c311

Please sign in to comment.