Core: Cleanup Variant comparison operators

This commit is contained in:
Thaddeus Crews 2025-11-05 19:22:41 -06:00
parent eb3d6d8cd3
commit cabbc616c2
No known key found for this signature in database
GPG key ID: 8C6E5FEB5FC03CCC
2 changed files with 6 additions and 15 deletions

View file

@ -865,17 +865,6 @@ bool Variant::operator==(const Variant &p_variant) const {
return hash_compare(p_variant);
}
bool Variant::operator!=(const Variant &p_variant) const {
// Don't use `!hash_compare(p_variant)` given it makes use of OP_EQUAL
if (type != p_variant.type) { //evaluation of operator== needs to be more strict
return true;
}
bool v;
Variant r;
evaluate(OP_NOT_EQUAL, *this, p_variant, r, v);
return r;
}
bool Variant::operator<(const Variant &p_variant) const {
if (type != p_variant.type) { //if types differ, then order by type first
return type < p_variant.type;

View file

@ -835,11 +835,13 @@ public:
static void get_utility_function_list(List<StringName> *r_functions);
static int get_utility_function_count();
//argsVariant call()
[[nodiscard]] bool operator==(const Variant &p_variant) const;
[[nodiscard]] bool operator<(const Variant &p_variant) const;
[[nodiscard]] _ALWAYS_INLINE_ bool operator!=(const Variant &p_variant) const { return !(*this == p_variant); }
[[nodiscard]] _ALWAYS_INLINE_ bool operator<=(const Variant &p_variant) const { return !(p_variant < *this); }
[[nodiscard]] _ALWAYS_INLINE_ bool operator>(const Variant &p_variant) const { return p_variant < *this; }
[[nodiscard]] _ALWAYS_INLINE_ bool operator>=(const Variant &p_variant) const { return !(*this < p_variant); }
bool operator==(const Variant &p_variant) const;
bool operator!=(const Variant &p_variant) const;
bool operator<(const Variant &p_variant) const;
uint32_t hash() const;
uint32_t recursive_hash(int recursion_count) const;