diff options
author | Bartłomiej T. Listwon <blistwon@gmail.com> | 2021-10-08 09:36:48 +0200 |
---|---|---|
committer | Bartłomiej T. Listwon <blistwon@gmail.com> | 2021-10-08 10:09:13 +0200 |
commit | 4a723842b6b8c2f60e0491ab4cb3daae717936fc (patch) | |
tree | e8e1e8b30119ddace08d6721329f055bd74cc90a | |
parent | 9b34442d93298c9e15f2068e2ba955c411aeb3af (diff) |
Faster hash_compare for integer and string keys in dictionaries
-rw-r--r-- | core/variant/variant.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
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<const String *>(_data._mem) == *reinterpret_cast<const String *>(p_variant._data._mem); + } break; + case VECTOR2: { const Vector2 *l = reinterpret_cast<const Vector2 *>(_data._mem); const Vector2 *r = reinterpret_cast<const Vector2 *>(p_variant._data._mem); |