From eb0b03c579cfd90ebfeeaa115955a0a924c9ce0f Mon Sep 17 00:00:00 2001 From: Volker Krause Date: Wed, 6 Jan 2016 15:39:01 +0100 Subject: QPair is too large for QList to be efficient-ish. Qt3D is making heavy use of this, causing the QList node allocations to be among the top 10 per frame allocation sources. Switching to QVector fixes that. Change-Id: I3b4df329710f82bf8d6797ea1f0c79b288a08063 Reviewed-by: Sean Harmer Reviewed-by: Marc Mutz --- src/corelib/thread/qthreadpool.cpp | 10 +++++----- src/corelib/thread/qthreadpool_p.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/corelib/thread/qthreadpool.cpp b/src/corelib/thread/qthreadpool.cpp index b6b3be8d92..e4a5368281 100644 --- a/src/corelib/thread/qthreadpool.cpp +++ b/src/corelib/thread/qthreadpool.cpp @@ -204,8 +204,8 @@ void QThreadPoolPrivate::enqueueTask(QRunnable *runnable, int priority) ++runnable->ref; // put it on the queue - QList >::const_iterator begin = queue.constBegin(); - QList >::const_iterator it = queue.constEnd(); + QVector >::const_iterator begin = queue.constBegin(); + QVector >::const_iterator it = queue.constEnd(); if (it != begin && priority > (*(it - 1)).second) it = std::upper_bound(begin, --it, priority); queue.insert(it - begin, qMakePair(runnable, priority)); @@ -299,7 +299,7 @@ bool QThreadPoolPrivate::waitForDone(int msecs) void QThreadPoolPrivate::clear() { QMutexLocker locker(&mutex); - for (QList >::const_iterator it = queue.constBegin(); + for (QVector >::const_iterator it = queue.constBegin(); it != queue.constEnd(); ++it) { QRunnable* r = it->first; if (r->autoDelete() && !--r->ref) @@ -319,8 +319,8 @@ bool QThreadPoolPrivate::stealRunnable(QRunnable *runnable) return false; { QMutexLocker locker(&mutex); - QList >::iterator it = queue.begin(); - QList >::iterator end = queue.end(); + QVector >::iterator it = queue.begin(); + QVector >::iterator end = queue.end(); while (it != end) { if (it->first == runnable) { diff --git a/src/corelib/thread/qthreadpool_p.h b/src/corelib/thread/qthreadpool_p.h index 34728ed3e2..b03eefcc94 100644 --- a/src/corelib/thread/qthreadpool_p.h +++ b/src/corelib/thread/qthreadpool_p.h @@ -83,7 +83,7 @@ public: QSet allThreads; QQueue waitingThreads; QQueue expiredThreads; - QList > queue; + QVector > queue; QWaitCondition noActiveThreads; bool isExiting; -- cgit v1.2.3