mirror of
https://github.com/greg7mdp/parallel-hashmap.git
synced 2026-08-30 00:50:38 +08:00
The default hash does not like using pointers as keys. #4
This commit is contained in:
Vendored
+2
-2
@@ -99,7 +99,7 @@ struct Hash<T *>
|
||||
{
|
||||
inline size_t operator()(const T *val) const noexcept
|
||||
{
|
||||
return phmap_mix_64(static_cast<const uintptr_t>(val));
|
||||
return phmap_mix_64((const uintptr_t)val);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -2547,7 +2547,7 @@ protected:
|
||||
bool operator==(const Inner& o) const
|
||||
{
|
||||
MutexLock_ m1(const_cast<Inner *>(this));
|
||||
MutexLock_ m2(const_cast<Inner *>(&o));
|
||||
MutexLock_ m2(const_cast<Inner *>(&o)); // deadlock - use std::lock
|
||||
return set_ == o.set_;
|
||||
}
|
||||
|
||||
|
||||
@@ -143,6 +143,14 @@ struct Eq {
|
||||
}
|
||||
};
|
||||
|
||||
TEST(THIS_TEST_NAME, PtrKet) {
|
||||
using H = THIS_HASH_MAP<void *, bool>;
|
||||
H hash;
|
||||
int a, b;
|
||||
hash.insert(H::value_type(&a, true));
|
||||
hash.insert(H::value_type(&b, false));
|
||||
};
|
||||
|
||||
TEST(THIS_TEST_NAME, LazyKeyPattern) {
|
||||
// hashes are only guaranteed in opt mode, we use assertions to track internal
|
||||
// state that can cause extra calls to hash.
|
||||
|
||||
Reference in New Issue
Block a user