Simplify qCompareThreeWay()
Use QtOrderingPrivate::reversed() in qCompareThreeWay() to avoid conversions to Qt::partial_ordering and Qt::strong_ordering. Task-number: QTBUG-119433 Pick-to: 6.7 Change-Id: Ia42bda518dcf23f5332cac9bb8d50baebef67e55 Reviewed-by: Marc Mutz <marc.mutz@qt.io>bb10
parent
5d590a38d9
commit
0995358efa
|
|
@ -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…
Reference in New Issue