Faster hash_compare for integer and string keys in dictionaries

This commit is contained in:
Bartłomiej T. Listwon 2021-10-08 10:08:27 +02:00
parent 06fc2378de
commit 5b4e3624f4

View file

@ -2789,10 +2789,18 @@ bool Variant::hash_compare(const Variant &p_variant) const {
}
switch (type) {
case INT: {
return _data._int == p_variant._data._int;
} break;
case REAL: {
return hash_compare_scalar(_data._real, p_variant._data._real);
} 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);