summaryrefslogtreecommitdiff
path: root/core/object
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2022-06-20 14:01:06 +0200
committerGitHub <noreply@github.com>2022-06-20 14:01:06 +0200
commit66a30dab35f3788ae28c7e6171d3908fe75e7b75 (patch)
treecc5045d98995b754097d1dde100f0138033fc735 /core/object
parent8e3d9a23aa0a724d3dd25fcf0e8085b5a438c233 (diff)
parent141c3755814cea60888c7ee548c7ce709550b784 (diff)
Merge pull request #62176 from reduz/cleanup-hashfuncs
Diffstat (limited to 'core/object')
-rw-r--r--core/object/callable_method_pointer.cpp4
-rw-r--r--core/object/class_db.cpp52
-rw-r--r--core/object/method_bind.cpp25
3 files changed, 38 insertions, 43 deletions
diff --git a/core/object/callable_method_pointer.cpp b/core/object/callable_method_pointer.cpp
index 1bf926cafc..81f8ab6be2 100644
--- a/core/object/callable_method_pointer.cpp
+++ b/core/object/callable_method_pointer.cpp
@@ -85,9 +85,9 @@ void CallableCustomMethodPointerBase::_setup(uint32_t *p_base_ptr, uint32_t p_pt
// Precompute hash.
for (uint32_t i = 0; i < comp_size; i++) {
if (i == 0) {
- h = hash_djb2_one_32(comp_ptr[i]);
+ h = hash_murmur3_one_32(comp_ptr[i]);
} else {
- h = hash_djb2_one_32(comp_ptr[i], h);
+ h = hash_murmur3_one_32(comp_ptr[i], h);
}
}
}
diff --git a/core/object/class_db.cpp b/core/object/class_db.cpp
index 533cb6e789..3c9f373d12 100644
--- a/core/object/class_db.cpp
+++ b/core/object/class_db.cpp
@@ -164,7 +164,7 @@ uint64_t ClassDB::get_api_hash(APIType p_api) {
OBJTYPE_RLOCK;
#ifdef DEBUG_METHODS_ENABLED
- uint64_t hash = hash_djb2_one_64(HashMapHasherDefault::hash(VERSION_FULL_CONFIG));
+ uint64_t hash = hash_murmur3_one_64(HashMapHasherDefault::hash(VERSION_FULL_CONFIG));
List<StringName> class_list;
ClassDB::get_class_list(&class_list);
@@ -177,8 +177,8 @@ uint64_t ClassDB::get_api_hash(APIType p_api) {
if (t->api != p_api || !t->exposed) {
continue;
}
- hash = hash_djb2_one_64(t->name.hash(), hash);
- hash = hash_djb2_one_64(t->inherits.hash(), hash);
+ hash = hash_murmur3_one_64(t->name.hash(), hash);
+ hash = hash_murmur3_one_64(t->inherits.hash(), hash);
{ //methods
@@ -200,27 +200,27 @@ uint64_t ClassDB::get_api_hash(APIType p_api) {
for (const StringName &F : snames) {
MethodBind *mb = t->method_map[F];
- hash = hash_djb2_one_64(mb->get_name().hash(), hash);
- hash = hash_djb2_one_64(mb->get_argument_count(), hash);
- hash = hash_djb2_one_64(mb->get_argument_type(-1), hash); //return
+ hash = hash_murmur3_one_64(mb->get_name().hash(), hash);
+ hash = hash_murmur3_one_64(mb->get_argument_count(), hash);
+ hash = hash_murmur3_one_64(mb->get_argument_type(-1), hash); //return
for (int i = 0; i < mb->get_argument_count(); i++) {
const PropertyInfo info = mb->get_argument_info(i);
- hash = hash_djb2_one_64(info.type, hash);
- hash = hash_djb2_one_64(info.name.hash(), hash);
- hash = hash_djb2_one_64(info.hint, hash);
- hash = hash_djb2_one_64(info.hint_string.hash(), hash);
+ hash = hash_murmur3_one_64(info.type, hash);
+ hash = hash_murmur3_one_64(info.name.hash(), hash);
+ hash = hash_murmur3_one_64(info.hint, hash);
+ hash = hash_murmur3_one_64(info.hint_string.hash(), hash);
}
- hash = hash_djb2_one_64(mb->get_default_argument_count(), hash);
+ hash = hash_murmur3_one_64(mb->get_default_argument_count(), hash);
for (int i = 0; i < mb->get_default_argument_count(); i++) {
//hash should not change, i hope for tis
Variant da = mb->get_default_argument(i);
- hash = hash_djb2_one_64(da.hash(), hash);
+ hash = hash_murmur3_one_64(da.hash(), hash);
}
- hash = hash_djb2_one_64(mb->get_hint_flags(), hash);
+ hash = hash_murmur3_one_64(mb->get_hint_flags(), hash);
}
}
@@ -235,8 +235,8 @@ uint64_t ClassDB::get_api_hash(APIType p_api) {
snames.sort_custom<StringName::AlphCompare>();
for (const StringName &F : snames) {
- hash = hash_djb2_one_64(F.hash(), hash);
- hash = hash_djb2_one_64(t->constant_map[F], hash);
+ hash = hash_murmur3_one_64(F.hash(), hash);
+ hash = hash_murmur3_one_64(t->constant_map[F], hash);
}
}
@@ -252,9 +252,9 @@ uint64_t ClassDB::get_api_hash(APIType p_api) {
for (const StringName &F : snames) {
MethodInfo &mi = t->signal_map[F];
- hash = hash_djb2_one_64(F.hash(), hash);
+ hash = hash_murmur3_one_64(F.hash(), hash);
for (int i = 0; i < mi.arguments.size(); i++) {
- hash = hash_djb2_one_64(mi.arguments[i].type, hash);
+ hash = hash_murmur3_one_64(mi.arguments[i].type, hash);
}
}
}
@@ -273,23 +273,23 @@ uint64_t ClassDB::get_api_hash(APIType p_api) {
PropertySetGet *psg = t->property_setget.getptr(F);
ERR_FAIL_COND_V(!psg, 0);
- hash = hash_djb2_one_64(F.hash(), hash);
- hash = hash_djb2_one_64(psg->setter.hash(), hash);
- hash = hash_djb2_one_64(psg->getter.hash(), hash);
+ hash = hash_murmur3_one_64(F.hash(), hash);
+ hash = hash_murmur3_one_64(psg->setter.hash(), hash);
+ hash = hash_murmur3_one_64(psg->getter.hash(), hash);
}
}
//property list
for (const PropertyInfo &F : t->property_list) {
- hash = hash_djb2_one_64(F.name.hash(), hash);
- hash = hash_djb2_one_64(F.type, hash);
- hash = hash_djb2_one_64(F.hint, hash);
- hash = hash_djb2_one_64(F.hint_string.hash(), hash);
- hash = hash_djb2_one_64(F.usage, hash);
+ hash = hash_murmur3_one_64(F.name.hash(), hash);
+ hash = hash_murmur3_one_64(F.type, hash);
+ hash = hash_murmur3_one_64(F.hint, hash);
+ hash = hash_murmur3_one_64(F.hint_string.hash(), hash);
+ hash = hash_murmur3_one_64(F.usage, hash);
}
}
- return hash;
+ return hash_fmix32(hash);
#else
return 0;
#endif
diff --git a/core/object/method_bind.cpp b/core/object/method_bind.cpp
index a208c1a2b2..a4474ea53b 100644
--- a/core/object/method_bind.cpp
+++ b/core/object/method_bind.cpp
@@ -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 {