diff options
author | Valentin Zagura <puthre@gmail.com> | 2019-09-09 10:39:40 +0100 |
---|---|---|
committer | Valentin Zagura <puthre@gmail.com> | 2019-09-09 10:39:40 +0100 |
commit | 6a36779e89c3183b6ef58e250bcd10735736d4d8 (patch) | |
tree | 6361dff4b3553cf6300f9b91f03d311b76837c2c | |
parent | 24e1039eb6fe32115e8d1a62a84965e9be19a2ed (diff) |
Optimized variant reference function.
Optimized critical execution path in Variant::reference by removing expensive and unnecessary call to clear for atomic types.
-rw-r--r-- | core/variant.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/core/variant.cpp b/core/variant.cpp index e7d0e58367..16bbf94c54 100644 --- a/core/variant.cpp +++ b/core/variant.cpp @@ -910,7 +910,15 @@ bool Variant::is_one() const { void Variant::reference(const Variant &p_variant) { - clear(); + switch (type) { + case NIL: + case BOOL: + case INT: + case REAL: + break; + default: + clear(); + } type = p_variant.type; |