diff --git a/AK/Traits.h b/AK/Traits.h index 19cc078122f..2f20cb82a99 100644 --- a/AK/Traits.h +++ b/AK/Traits.h @@ -23,52 +23,16 @@ template struct Traits : public GenericTraits { }; -template<> -struct Traits : public GenericTraits { +template +requires(IsIntegral) struct Traits : public GenericTraits { static constexpr bool is_trivial() { return true; } - static unsigned hash(int i) { return int_hash(i); } -}; - -template<> -struct Traits : public GenericTraits { - static constexpr bool is_trivial() { return true; } - static unsigned hash(char c) { return int_hash(c); } -}; - -template<> -struct Traits : public GenericTraits { - static constexpr bool is_trivial() { return true; } - static unsigned hash(i16 i) { return int_hash(i); } -}; - -template<> -struct Traits : public GenericTraits { - static constexpr bool is_trivial() { return true; } - static unsigned hash(i64 i) { return u64_hash(i); } -}; - -template<> -struct Traits : public GenericTraits { - static constexpr bool is_trivial() { return true; } - static unsigned hash(unsigned u) { return int_hash(u); } -}; - -template<> -struct Traits : public GenericTraits { - static constexpr bool is_trivial() { return true; } - static unsigned hash(u8 u) { return int_hash(u); } -}; - -template<> -struct Traits : public GenericTraits { - static constexpr bool is_trivial() { return true; } - static unsigned hash(u16 u) { return int_hash(u); } -}; - -template<> -struct Traits : public GenericTraits { - static constexpr bool is_trivial() { return true; } - static unsigned hash(u64 u) { return u64_hash(u); } + static constexpr unsigned hash(T value) + { + if constexpr (sizeof(T) < 8) + return int_hash(value); + else + return u64_hash(value); + } }; template