Skip to content

Commit

Permalink
AK: Make Traits<T*> use ptr_hash() and not assume 32-bit pointers
Browse files Browse the repository at this point in the history
As a nice bonus, it also simplifies the code quite a bit.
  • Loading branch information
alimpfard committed Jul 12, 2021
1 parent ad328f8 commit 8776f42
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions AK/Traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,9 @@ requires(IsIntegral<T>) struct Traits<T> : public GenericTraits<T> {
};

template<typename T>
struct Traits<T*> : public GenericTraits<T*> {
static unsigned hash(const T* p)
{
return int_hash((unsigned)(__PTRDIFF_TYPE__)p);
}
requires(IsPointer<T>) struct Traits<T> : public GenericTraits<T> {
static unsigned hash(T p) { return ptr_hash((FlatPtr)p); }
static constexpr bool is_trivial() { return true; }
static bool equals(const T* a, const T* b) { return a == b; }
};

}
Expand Down

0 comments on commit 8776f42

Please sign in to comment.