Optimise QMutexLocker a little: don't call relock() in the constructor
QMutexLocker does not support being passed already-locked mutexes, unless they are recursive mutexes. But in that case, it behaves as if the mutex weren't locked in the first place. Since that's the case, there's no point in testing the low bit to see if it's set or not. It's never going to be. Change-Id: Ie4b81f7e2cca16e6db36f3cb51a5377dbdfc157d Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
This commit is contained in:
parent
96bc8835eb
commit
38dc1f7597
@ -116,8 +116,11 @@ public:
|
||||
Q_ASSERT_X((reinterpret_cast<quintptr>(m) & quintptr(1u)) == quintptr(0),
|
||||
"QMutexLocker", "QMutex pointer is misaligned");
|
||||
val = quintptr(m);
|
||||
// relock() here ensures that we call QMutex::lock() instead of QBasicMutex::lock()
|
||||
relock();
|
||||
if (Q_LIKELY(m)) {
|
||||
// call QMutex::lock() instead of QBasicMutex::lock()
|
||||
static_cast<QMutex *>(m)->lock();
|
||||
val |= 1;
|
||||
}
|
||||
}
|
||||
inline ~QMutexLocker() { unlock(); }
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user