diff options
Diffstat (limited to 'core/variant.h')
-rw-r--r-- | core/variant.h | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/core/variant.h b/core/variant.h index 8e924be00a..b24cf968de 100644 --- a/core/variant.h +++ b/core/variant.h @@ -123,10 +123,9 @@ private: // Variant takes 20 bytes when real_t is float, and 36 if double // it only allocates extra memory for aabb/matrix. - Type type; + Type type = NIL; struct ObjData { - ObjectID id; Object *obj; }; @@ -403,7 +402,6 @@ public: static String get_operator_name(Operator p_op); static void evaluate(const Operator &p_op, const Variant &p_a, const Variant &p_b, Variant &r_ret, bool &r_valid); static _FORCE_INLINE_ Variant evaluate(const Operator &p_op, const Variant &p_a, const Variant &p_b) { - bool valid = true; Variant res; evaluate(p_op, p_a, p_b, res, valid); @@ -469,13 +467,13 @@ public: static void construct_from_string(const String &p_string, Variant &r_value, ObjectConstruct p_obj_construct = nullptr, void *p_construct_ud = nullptr); void operator=(const Variant &p_variant); // only this is enough for all the other types + Variant(const Variant &p_variant); - _FORCE_INLINE_ Variant() { - type = NIL; - } + _FORCE_INLINE_ Variant() {} _FORCE_INLINE_ ~Variant() { - if (type != Variant::NIL) + if (type != Variant::NIL) { clear(); + } } }; @@ -490,22 +488,18 @@ Vector<Variant> varray(const Variant &p_arg1, const Variant &p_arg2, const Varia Vector<Variant> varray(const Variant &p_arg1, const Variant &p_arg2, const Variant &p_arg3, const Variant &p_arg4, const Variant &p_arg5); struct VariantHasher { - static _FORCE_INLINE_ uint32_t hash(const Variant &p_variant) { return p_variant.hash(); } }; struct VariantComparator { - static _FORCE_INLINE_ bool compare(const Variant &p_lhs, const Variant &p_rhs) { return p_lhs.hash_compare(p_rhs); } }; Variant::ObjData &Variant::_get_obj() { - return *reinterpret_cast<ObjData *>(&_data._mem[0]); } const Variant::ObjData &Variant::_get_obj() const { - return *reinterpret_cast<const ObjData *>(&_data._mem[0]); } |