From adb4a3beb7a0e02d4e4f96dadaa6587298c4d1f5 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 17 May 2022 17:19:54 +0200 Subject: [PATCH] Optimize atomics in QObject::moveToThread() [1/2]: relax a pointer load We don't need an acquire fence for checking a pointer for nullness, and we're not dereferencing the pointer later, so use a relaxed load there. Pick-to: 6.3 Change-Id: Id84e6fc50100f1bf6a4e33f89424f8b1cbb250cd Reviewed-by: Thiago Macieira --- src/corelib/kernel/qobject.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index e15dbde52e3..6dfa7c3e674 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -1818,7 +1818,7 @@ void QObject::moveToThread(QThread *targetThread) QThreadData *currentData = QThreadData::current(); QThreadData *targetData = targetThread ? QThreadData::get2(targetThread) : nullptr; QThreadData *thisThreadData = d->threadData.loadAcquire(); - if (!thisThreadData->thread.loadAcquire() && currentData == targetData) { + if (!thisThreadData->thread.loadRelaxed() && currentData == targetData) { // one exception to the rule: we allow moving objects with no thread affinity to the current thread currentData = d->threadData; } else if (thisThreadData != currentData) {