You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-12-05 17:15:09 +00:00
Clean up Hash Functions
Clean up and do fixes to hash functions and newly introduced murmur3 hashes in #61934 * Clean up usage of murmur3 * Fixed usages of binary murmur3 on floats (this is invalid) * Changed DJB2 to use xor (which seems to be better)
This commit is contained in:
@@ -35,32 +35,27 @@
|
||||
#include "method_bind.h"
|
||||
|
||||
uint32_t MethodBind::get_hash() const {
|
||||
uint32_t hash = hash_djb2_one_32(has_return() ? 1 : 0);
|
||||
hash = hash_djb2_one_32(get_argument_count(), hash);
|
||||
|
||||
#ifndef _MSC_VER
|
||||
#warning This needs proper class name and argument type for hashing
|
||||
#endif
|
||||
#if 0
|
||||
uint32_t hash = hash_murmur3_one_32(has_return() ? 1 : 0);
|
||||
hash = hash_murmur3_one_32(get_argument_count(), hash);
|
||||
|
||||
for (int i = (has_return() ? -1 : 0); i < get_argument_count(); i++) {
|
||||
PropertyInfo pi = i == -1 ? get_return_info() : get_argument_info(i);
|
||||
hash = hash_djb2_one_32(get_argument_type(i), hash);
|
||||
hash = hash_murmur3_one_32(get_argument_type(i), hash);
|
||||
if (pi.class_name != StringName()) {
|
||||
hash = hash_djb2_one_32(pi.class_name.operator String().hash(), hash);
|
||||
hash = hash_murmur3_one_32(pi.class_name.operator String().hash(), hash);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
hash = hash_djb2_one_32(get_default_argument_count(), hash);
|
||||
|
||||
hash = hash_murmur3_one_32(get_default_argument_count(), hash);
|
||||
for (int i = 0; i < get_default_argument_count(); i++) {
|
||||
Variant v = get_default_argument(i);
|
||||
hash = hash_djb2_one_32(v.hash(), hash);
|
||||
hash = hash_murmur3_one_32(v.hash(), hash);
|
||||
}
|
||||
|
||||
hash = hash_djb2_one_32(is_const(), hash);
|
||||
hash = hash_djb2_one_32(is_vararg(), hash);
|
||||
hash = hash_murmur3_one_32(is_const(), hash);
|
||||
hash = hash_murmur3_one_32(is_vararg(), hash);
|
||||
|
||||
return hash;
|
||||
return hash_fmix32(hash);
|
||||
}
|
||||
|
||||
PropertyInfo MethodBind::get_argument_info(int p_argument) const {
|
||||
|
||||
Reference in New Issue
Block a user