From 404305980c72f077b1f0972713453325d4c629d0 Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Sun, 21 Mar 2021 16:34:16 +0200 Subject: [PATCH] QVariant comparison optimization Signed-off-by: Ivailo Monev --- src/core/kernel/qvariant.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/core/kernel/qvariant.cpp b/src/core/kernel/qvariant.cpp index 8f95ef0e4..ecaf98b1c 100644 --- a/src/core/kernel/qvariant.cpp +++ b/src/core/kernel/qvariant.cpp @@ -2973,18 +2973,18 @@ static inline bool qIsFloatingPoint(int tp) */ bool QVariant::cmp(const QVariant &v) const { - QVariant v2 = v; - if (d.type != v2.d.type) { + if (d.type != v.d.type) { if (qIsNumericType(d.type) && qIsNumericType(v.d.type)) { if (qIsFloatingPoint(d.type) || qIsFloatingPoint(v.d.type)) return qFuzzyCompare(toReal(), v.toReal()); - else - return toLongLong() == v.toLongLong(); + return toLongLong() == v.toLongLong(); } - if (!v2.canConvert(Type(d.type)) || !v2.convert(Type(d.type))) + QVariant v2(v); + if (!v2.convert(Type(d.type))) return false; + return handler->compare(&d, &v2.d); } - return handler->compare(&d, &v2.d); + return handler->compare(&d, &v.d); } /*! \internal