Skip to content

Commit 43f5ad3

Browse files
Refactor xxhash template functions to use fixed seed parameter
1 parent f280e2b commit 43f5ad3

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

src/util/serialise/xxhash.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ namespace util {
4747
uint32_t xxhash32(const T& input, const uint32_t& seed = 0) {
4848
return xxhash32(reinterpret_cast<const char*>(&input), sizeof(T), seed);
4949
}
50-
template <size_t N>
51-
uint32_t xxhash32(const char (&input)[N], const uint32_t& seed = 0) {
52-
return xxhash32(input, N - 1, seed);
50+
template <uint32_t S = 0, size_t N>
51+
uint32_t xxhash32(const char (&input)[N]) {
52+
return xxhash32(input, N - 1, S);
5353
}
5454

5555
/**
@@ -69,9 +69,9 @@ namespace util {
6969
uint64_t xxhash64(const T& input, const uint64_t& seed = 0) {
7070
return xxhash64(reinterpret_cast<const char*>(&input), sizeof(T), seed);
7171
}
72-
template <size_t N>
73-
uint64_t xxhash64(const char (&input)[N], const uint64_t& seed = 0) {
74-
return xxhash64(input, N - 1, seed);
72+
template <uint64_t S = 0, size_t N>
73+
uint64_t xxhash64(const char (&input)[N]) {
74+
return xxhash64(input, N - 1, S);
7575
}
7676

7777
} // namespace serialise

tests/tests/util/serialise/xxhash.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ namespace util {
209209
// Match with and without seed
210210
const char* str = "FooBar";
211211
CHECK(xxhash32("FooBar") == xxhash32(str, std::strlen(str)));
212-
CHECK(xxhash32("FooBar", fixed_seed) == xxhash32(str, std::strlen(str), fixed_seed));
212+
CHECK(xxhash32<fixed_seed>("FooBar") == xxhash32(str, std::strlen(str), fixed_seed));
213213
}
214214
}
215215

@@ -218,7 +218,7 @@ namespace util {
218218
// Match with and without seed
219219
const char* str = "FooBar";
220220
CHECK(xxhash64("FooBar") == xxhash64(str, std::strlen(str)));
221-
CHECK(xxhash64("FooBar", uint64_t(fixed_seed)) == xxhash64(str, std::strlen(str), fixed_seed));
221+
CHECK(xxhash64<fixed_seed>("FooBar") == xxhash64(str, std::strlen(str), fixed_seed));
222222
}
223223
}
224224
}

0 commit comments

Comments
 (0)