QMutex: mark the uncontended paths as Q_LIKELY

Change-Id: I72ae8d8975c26d1f2e81fffd5839a2500f5edcb6
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
This commit is contained in:
Thiago Macieira 2025-02-13 16:33:28 -08:00
parent acde39e102
commit 51bc150382
1 changed files with 2 additions and 2 deletions

View File

@ -55,7 +55,7 @@ public:
if constexpr (FutexAlwaysAvailable) { if constexpr (FutexAlwaysAvailable) {
// we always unlock if we have futexes // we always unlock if we have futexes
if (QMutexPrivate *d = d_ptr.fetchAndStoreRelease(nullptr); d != dummyLocked()) if (QMutexPrivate *d = d_ptr.fetchAndStoreRelease(nullptr); Q_UNLIKELY(d != dummyLocked()))
unlockInternalFutex(d); // was contended unlockInternalFutex(d); // was contended
} else { } else {
// if we don't have futexes, we can only unlock if not contended // if we don't have futexes, we can only unlock if not contended
@ -85,7 +85,7 @@ public:
private: private:
inline bool fastTryLock() noexcept inline bool fastTryLock() noexcept
{ {
if (d_ptr.loadRelaxed() != nullptr) if (Q_UNLIKELY(d_ptr.loadRelaxed() != nullptr))
return false; return false;
return d_ptr.testAndSetAcquire(nullptr, dummyLocked()); return d_ptr.testAndSetAcquire(nullptr, dummyLocked());
} }