OSDN Git Service

Revert "avoid temporary copy in QVariant::cmp()"
authorIvailo Monev <xakepa10@laimg.moc>
Wed, 4 Dec 2019 19:40:09 +0000 (19:40 +0000)
committerIvailo Monev <xakepa10@laimg.moc>
Wed, 4 Dec 2019 19:40:09 +0000 (19:40 +0000)
This reverts commit 0f37127b5e5bf61c6e008cb100d5fd9c67bc434a.

src/core/kernel/qvariant.cpp

index e0ba5ac..4d0db8e 100644 (file)
@@ -3125,18 +3125,18 @@ static inline bool qIsFloatingPoint(uint tp)
  */
 bool QVariant::cmp(const QVariant &v) const
 {
-    if (d.type != v.d.type) {
+    QVariant v2 = v;
+    if (d.type != v2.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();
         }
-        QVariant v2 = v;
-        if (!v.canConvert(Type(d.type)) || !v2.convert(Type(d.type)))
+        if (!v2.canConvert(Type(d.type)) || !v2.convert(Type(d.type)))
             return false;
     }
-    return handler->compare(&d, &v.d);
+    return handler->compare(&d, &v2.d);
 }
 
 /*! \internal