Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions src/util/serialise/xxhash.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,13 @@ namespace util {
uint32_t xxhash32(const char* input, const size_t& length, const uint32_t& seed = 0);

template <typename T>
uint32_t xxhash32(const T* input, const uint32_t& seed = 0) {
return xxhash32(reinterpret_cast<const char*>(input), sizeof(T), seed);
uint32_t xxhash32(const T& input, const uint32_t& seed = 0) {
return xxhash32(reinterpret_cast<const char*>(&input), sizeof(T), seed);
}
template <uint32_t S = 0, size_t N>
// NOLINTNEXTLINE(cppcoreguidelines-avoid-c-arrays,modernize-avoid-c-arrays)
uint32_t xxhash32(const char (&input)[N]) {
return xxhash32(input, N - 1, S);
}

/**
Expand All @@ -62,8 +67,13 @@ namespace util {
uint64_t xxhash64(const char* input, const size_t& length, const uint64_t& seed = 0);

template <typename T>
uint64_t xxhash64(const T* input, const uint64_t& seed = 0) {
return xxhash64(reinterpret_cast<const char*>(input), sizeof(T), seed);
uint64_t xxhash64(const T& input, const uint64_t& seed = 0) {
return xxhash64(reinterpret_cast<const char*>(&input), sizeof(T), seed);
}
template <uint64_t S = 0, size_t N>
// NOLINTNEXTLINE(cppcoreguidelines-avoid-c-arrays,modernize-avoid-c-arrays)
uint64_t xxhash64(const char (&input)[N]) {
return xxhash64(input, N - 1, S);
}

} // namespace serialise
Expand Down
Loading
Loading