Skip to content

armgit / godot

Public Imported from GitHub
0

Godot Engine – Multi-platform 2D and 3D game engine

Fix hash function for `const char *` producing a pointer-based hash instead of a string-based hash.

Lukas Tenbrink96f9d8f19ca2
diff --git a/core/templates/hashfuncs.h b/core/templates/hashfuncs.h
index 1047915ee45..4d2415ccd94 100644
--- a/core/templates/hashfuncs.h
+++ b/core/templates/hashfuncs.h
@@ -207,6 +207,9 @@ struct HashMapHasherDefaultImpl<char *> {
static _FORCE_INLINE_ uint32_t hash(const char *p_cstr) { return hash_djb2(p_cstr); }
};
+template <>
+struct HashMapHasherDefaultImpl<const char *> : HashMapHasherDefaultImpl<char *> {};
+
template <>
struct HashMapHasherDefaultImpl<wchar_t> {
static _FORCE_INLINE_ uint32_t hash(const wchar_t p_wchar) { return hash_fmix32(uint32_t(p_wchar)); }