diff --git a/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeNumberFormat.cpp b/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeNumberFormat.cpp index 153fa82c26..3508960e9b 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeNumberFormat.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeNumberFormat.cpp @@ -130,20 +130,6 @@ struct AK::Traits : public GenericTraits { }; using NumberFormatList = Vector; - -template<> -struct AK::Traits : public GenericTraits { - static unsigned hash(NumberFormatList const& formats) - { - auto hash = int_hash(static_cast(formats.size())); - - for (auto format : formats) - hash = pair_int_hash(hash, format); - - return hash; - } -}; - using NumericSymbolList = Vector; struct NumberSystem { diff --git a/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GeneratorUtil.h b/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GeneratorUtil.h index aff59fe3f1..74621fbbc2 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GeneratorUtil.h +++ b/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GeneratorUtil.h @@ -7,6 +7,7 @@ #pragma once #include +#include #include #include #include @@ -14,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -25,6 +27,26 @@ inline constexpr bool StorageTypeIsList = false; template inline constexpr bool StorageTypeIsList> = true; +template +concept IntegralOrEnum = Integral || Enum; + +template +struct AK::Traits> : public GenericTraits> { + static unsigned hash(Vector const& list) + { + auto hash = int_hash(static_cast(list.size())); + + for (auto value : list) { + if constexpr (Enum) + hash = pair_int_hash(hash, to_underlying(value)); + else + hash = pair_int_hash(hash, value); + } + + return hash; + } +}; + template class UniqueStorage { public: