From e7a9c8a559bb46689d4a184df795c43f551abfef Mon Sep 17 00:00:00 2001 From: Ivan Solovev Date: Mon, 8 Jan 2024 15:53:05 +0100 Subject: [PATCH] Simplify qCompareThreeWay() Use QtOrderingPrivate::reversed() in qCompareThreeWay() to avoid conversions to Qt::partial_ordering and Qt::strong_ordering. Task-number: QTBUG-119433 Change-Id: Ia42bda518dcf23f5332cac9bb8d50baebef67e55 Reviewed-by: Marc Mutz (cherry picked from commit 0995358efabc91504f2ede20c724307358f9a276) Reviewed-by: Qt Cherry-pick Bot --- src/corelib/global/qcompare.h | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/corelib/global/qcompare.h b/src/corelib/global/qcompare.h index 9e67bdaa94e..5d4bb57e73d 100644 --- a/src/corelib/global/qcompare.h +++ b/src/corelib/global/qcompare.h @@ -657,14 +657,7 @@ auto qCompareThreeWay(const LT &lhs, const RT &rhs) return compareThreeWay(lhs, rhs); } else { const auto retval = compareThreeWay(rhs, lhs); - // We can compare any ordering type with Qt::partial_ordering, but we - // always need to return the right type. Use Qt::strong_ordering for - // casting, as it can be cast to any ordering type. - if (retval == Qt::partial_ordering::less) - return static_cast(Qt::strong_ordering::greater); - else if (retval == Qt::partial_ordering::greater) - return static_cast(Qt::strong_ordering::less); - return retval; + return QtOrderingPrivate::reversed(retval); } }