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 <marc.mutz@qt.io> (cherry picked from commit 0995358efabc91504f2ede20c724307358f9a276) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
82105e82e5
commit
e7a9c8a559
@ -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<decltype(retval)>(Qt::strong_ordering::greater);
|
||||
else if (retval == Qt::partial_ordering::greater)
|
||||
return static_cast<decltype(retval)>(Qt::strong_ordering::less);
|
||||
return retval;
|
||||
return QtOrderingPrivate::reversed(retval);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user