OSDN Git Service

mark some QThreadPool branches as unlikely
authorIvailo Monev <xakepa10@gmail.com>
Sat, 14 Jan 2023 03:42:31 +0000 (05:42 +0200)
committerIvailo Monev <xakepa10@gmail.com>
Sat, 14 Jan 2023 03:42:48 +0000 (05:42 +0200)
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
src/core/thread/qthreadpool.cpp

index b3a88d8..c045801 100644 (file)
@@ -374,7 +374,7 @@ QThreadPool *QThreadPool::globalInstance()
 */
 void QThreadPool::start(QRunnable *runnable, int priority)
 {
-    if (!runnable) {
+    if (Q_UNLIKELY(!runnable)) {
         return;
     }
 
@@ -408,7 +408,7 @@ void QThreadPool::start(QRunnable *runnable, int priority)
 */
 bool QThreadPool::tryStart(QRunnable *runnable)
 {
-    if (!runnable) {
+    if (Q_UNLIKELY(!runnable)) {
         return false;
     }
 
@@ -475,8 +475,9 @@ void QThreadPool::setMaxThreadCount(int maxThreadCount)
     Q_D(QThreadPool);
     QMutexLocker locker(&d->mutex);
 
-    if (maxThreadCount == d->maxThreadCount)
+    if (maxThreadCount == d->maxThreadCount) {
         return;
+    }
 
     d->maxThreadCount = maxThreadCount;
     d->tryToStartMoreThreads();
@@ -558,7 +559,7 @@ void QThreadPool::waitForDone()
 bool QThreadPool::waitForDone(int msecs)
 {
     Q_D(QThreadPool);
-    bool rc = d->waitForDone(msecs);
+    const bool rc = d->waitForDone(msecs);
     if (rc) {
         d->reset();
     }