Skip to content

Commit

Permalink
perf and bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanfred authored and ByteHamster committed Dec 3, 2024
1 parent 68e56d8 commit ceffe8d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
13 changes: 6 additions & 7 deletions include/utils/hasher.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

// See also https://github.com/jermp/bench_hash_functions

#include <xxhash.h>
#include <xxh3.h>

namespace pthash {
Expand Down Expand Up @@ -171,7 +170,7 @@ struct murmurhash2_64 {
typedef hash64 hash_type;

// generic range of bytes
static inline hash64 hash(byte_range range, uint64_t seed) {
static inline hash64 hash(byte_range const& range, uint64_t seed) {
return MurmurHash2_64(range.begin, range.end - range.begin, seed);
}

Expand All @@ -181,7 +180,7 @@ struct murmurhash2_64 {
}

// specialization for uint64_t
static inline hash64 hash(uint64_t val, uint64_t seed) {
static inline hash64 hash(uint64_t const& val, uint64_t seed) {
return MurmurHash2_64(reinterpret_cast<char const*>(&val), sizeof(val), seed);
}
};
Expand All @@ -190,7 +189,7 @@ struct murmurhash2_128 {
typedef hash128 hash_type;

// generic range of bytes
static inline hash128 hash(byte_range range, uint64_t seed) {
static inline hash128 hash(byte_range const& range, uint64_t seed) {
return {MurmurHash2_64(range.begin, range.end - range.begin, seed),
MurmurHash2_64(range.begin, range.end - range.begin, ~seed)};
}
Expand All @@ -202,7 +201,7 @@ struct murmurhash2_128 {
}

// specialization for uint64_t
static inline hash128 hash(uint64_t val, uint64_t seed) {
static inline hash128 hash(uint64_t const& val, uint64_t seed) {
return {MurmurHash2_64(reinterpret_cast<char const*>(&val), sizeof(val), seed),
MurmurHash2_64(reinterpret_cast<char const*>(&val), sizeof(val), ~seed)};
}
Expand All @@ -217,12 +216,12 @@ struct xxhash128 {
}

// specialization for uint64_t
static inline hash_type hash(uint64_t val, uint64_t seed) {
static inline hash_type hash(uint64_t const& val, uint64_t seed) {
return XXH128(&val, sizeof(val), seed);
}

// specialization for std::pair<uint64_t, uint64_t>
static inline hash_type hash(std::pair<uint64_t, uint64_t> val, uint64_t seed) {
static inline hash_type hash(std::pair<uint64_t, uint64_t> const& val, uint64_t seed) {
return XXH128(&val, sizeof(val), seed);
}
};
Expand Down
2 changes: 1 addition & 1 deletion src/example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ int main() {
// pthash_type;

typedef dense_partitioned_phf<xxhash128, // base hasher
opt_bucketer, // bucketer
table_bucketer<opt_bucketer>, // bucketer
inter_R, // encoder type
true, // minimal
pthash_search_type::add_displacement // additive displacement
Expand Down

0 comments on commit ceffe8d

Please sign in to comment.