QVersionNumber: add missing size check for comparesEqual()
The whole point of separating comparesEqual() and compareThreeWay() is that the former can fail faster than the latter. To wit: segmentCount() is an inline operation and, for the common case of SSO storage, a single byte read. compare(), OTOH, is an out-of-line call. So compare the segmentCount() before calling compare(). Amends ecb0878cbc3bc677d0f440950d2d1e304bcea495. Change-Id: I3e46e73d4b8827532cc16428ca5e7f25bfa8608e Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> (cherry picked from commit 9bd3d39b3fe2d760b9c484663bdc6c863a68e22e) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
a2d858febf
commit
b0e9c0d740
@ -360,7 +360,7 @@ private:
|
||||
[[nodiscard]] friend bool comparesEqual(const QVersionNumber &lhs,
|
||||
const QVersionNumber &rhs) noexcept
|
||||
{
|
||||
return compare(lhs, rhs) == 0;
|
||||
return lhs.segmentCount() == rhs.segmentCount() && compare(lhs, rhs) == 0;
|
||||
}
|
||||
[[nodiscard]] friend Qt::strong_ordering compareThreeWay(const QVersionNumber &lhs,
|
||||
const QVersionNumber &rhs) noexcept
|
||||
|
Loading…
x
Reference in New Issue
Block a user