From 4a723842b6b8c2f60e0491ab4cb3daae717936fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20T=2E=20Listwon?= Date: Fri, 8 Oct 2021 09:36:48 +0200 Subject: Faster hash_compare for integer and string keys in dictionaries --- core/variant/variant.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'core/variant') diff --git a/core/variant/variant.cpp b/core/variant/variant.cpp index 0dbeb6e4cb..86d772fb07 100644 --- a/core/variant/variant.cpp +++ b/core/variant/variant.cpp @@ -3145,10 +3145,18 @@ bool Variant::hash_compare(const Variant &p_variant) const { } switch (type) { + case INT: { + return _data._int == p_variant._data._int; + } break; + case FLOAT: { return hash_compare_scalar(_data._float, p_variant._data._float); } break; + case STRING: { + return *reinterpret_cast(_data._mem) == *reinterpret_cast(p_variant._data._mem); + } break; + case VECTOR2: { const Vector2 *l = reinterpret_cast(_data._mem); const Vector2 *r = reinterpret_cast(p_variant._data._mem); -- cgit v1.2.3