Rewrite HashMapHasherDefault based on type traits - it is now possible to declare a default hashing function for any type.
Remove cross-project includes from `hashfuncs.h`. Improve hashing function for `Color` (based on values instead of `String`). Move `Variant` comparison from `hash_map.h` to `dictionary.cpp` (`VariantComparatorDictionary`), where it's used. Remove now unnecessary `HashableHasher`.
This commit is contained in:
@ -32,6 +32,7 @@
|
||||
|
||||
#include "core/error/error_macros.h"
|
||||
#include "core/math/math_funcs.h"
|
||||
#include "core/templates/hashfuncs.h"
|
||||
|
||||
class String;
|
||||
struct Vector2;
|
||||
@ -147,6 +148,12 @@ struct [[nodiscard]] Vector2i {
|
||||
explicit operator String() const;
|
||||
operator Vector2() const;
|
||||
|
||||
uint32_t hash() const {
|
||||
uint32_t h = hash_murmur3_one_32(uint32_t(x));
|
||||
h = hash_murmur3_one_32(uint32_t(y), h);
|
||||
return hash_fmix32(h);
|
||||
}
|
||||
|
||||
// NOLINTBEGIN(cppcoreguidelines-pro-type-member-init)
|
||||
constexpr Vector2i() :
|
||||
x(0), y(0) {}
|
||||
|
||||
Reference in New Issue
Block a user