From cabbc616c2930cd9fb44179d31cef64c1c81516f Mon Sep 17 00:00:00 2001 From: Thaddeus Crews Date: Wed, 5 Nov 2025 19:22:41 -0600 Subject: [PATCH] Core: Cleanup `Variant` comparison operators --- core/variant/variant.cpp | 11 ----------- core/variant/variant.h | 10 ++++++---- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/core/variant/variant.cpp b/core/variant/variant.cpp index 9077a3140c..b28419cc33 100644 --- a/core/variant/variant.cpp +++ b/core/variant/variant.cpp @@ -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; diff --git a/core/variant/variant.h b/core/variant/variant.h index e6635efd2e..ec67f85f48 100644 --- a/core/variant/variant.h +++ b/core/variant/variant.h @@ -835,11 +835,13 @@ public: static void get_utility_function_list(List *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;