aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/util/qquickpixmapcache.cpp
diff options
context:
space:
mode:
authorFrank Meerkoetter <frank.meerkoetter@basyskom.com>2016-05-13 10:17:42 +0200
committerFrank Meerkoetter <frank.meerkoetter@basyskom.com>2016-05-13 10:57:35 +0000
commitec78cd1d22f943aa638749a8d3670e0138122c4a (patch)
treee5e3719d79e179b9b9df86a7c017cc18eb595a35 /src/quick/util/qquickpixmapcache.cpp
parent5241bcecea1b357dfe614346ae58e78ffd9578f8 (diff)
Avoid memory allocations
Avoids at least three memory allocations (values() twice and a local QList for the result of a concatenation. Change-Id: I83776652ddd30642e25144f5b173dd6b1074ac79 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Diffstat (limited to 'src/quick/util/qquickpixmapcache.cpp')
-rw-r--r--src/quick/util/qquickpixmapcache.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/quick/util/qquickpixmapcache.cpp b/src/quick/util/qquickpixmapcache.cpp
index 2b6e8f68c3..597613c9fd 100644
--- a/src/quick/util/qquickpixmapcache.cpp
+++ b/src/quick/util/qquickpixmapcache.cpp
@@ -455,13 +455,19 @@ QQuickPixmapReader::~QQuickPixmapReader()
}
jobs.clear();
#ifndef QT_NO_NETWORK
- QList<QQuickPixmapReply*> activeJobs = networkJobs.values() + asyncResponses.values();
- foreach (QQuickPixmapReply *reply, activeJobs ) {
+
+ const auto cancelJob = [this](QQuickPixmapReply *reply) {
if (reply->loading) {
cancelled.append(reply);
reply->data = 0;
}
- }
+ };
+
+ for (auto *reply : qAsConst(networkJobs))
+ cancelJob(reply);
+
+ for (auto *reply : qAsConst(asyncResponses))
+ cancelJob(reply);
#endif
if (threadObject) threadObject->processJobs();
mutex.unlock();