From 5af12dae41da231c9e8fa25478605a760ccb03bd Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 28 Jan 2016 16:09:46 +0100 Subject: qmake: replace a QLinkedList with QVector In VcprojGenerator::collectDependencies(), a temporary QLinkedList is created, then iterated over. There's no reason to use a node- based container here: no references are taken, no erases happen, esp. not in the middle... Port to QVector instead and reserve it, since the maximum size is known ahead of time, and the lifetime of the container is very short. Since the loop iterating over the linked list needed touching anyway, port directly to C++11 range-for. Change-Id: Ic5dfeebcd9da37c214f54abc6025a0a2b8fa3b5d Reviewed-by: Oswald Buddenhagen Reviewed-by: Lars Knoll --- qmake/generators/win32/msvc_vcproj.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp index cb0b1b1331..d473f3df9f 100644 --- a/qmake/generators/win32/msvc_vcproj.cpp +++ b/qmake/generators/win32/msvc_vcproj.cpp @@ -434,10 +434,12 @@ ProStringList VcprojGenerator::collectDependencies(QMakeProject *proj, QHash &subdirProjectLookup, const ProStringList &allDependencies) { - QLinkedList > collectedSubdirs; + QVector > collectedSubdirs; ProStringList tmp_proj_subdirs = proj->values("SUBDIRS"); ProStringList projectsInProject; - for(int x = 0; x < tmp_proj_subdirs.size(); ++x) { + const int numSubdirs = tmp_proj_subdirs.size(); + collectedSubdirs.reserve(numSubdirs); + for (int x = 0; x < numSubdirs; ++x) { ProString tmpdir = tmp_proj_subdirs.at(x); const ProKey tmpdirConfig(tmpdir + ".CONFIG"); if (!proj->isEmpty(tmpdirConfig)) { @@ -459,9 +461,7 @@ ProStringList VcprojGenerator::collectDependencies(QMakeProject *proj, QHashvalues(ProKey(tmp_proj_subdirs.at(x) + ".depends")))); projLookup.insert(tmp_proj_subdirs.at(x).toQString(), tmpdir.toQString()); } - QLinkedListIterator > collectedIt(collectedSubdirs); - while (collectedIt.hasNext()) { - QPair subdir = collectedIt.next(); + for (const auto &subdir : qAsConst(collectedSubdirs)) { QString profile = subdir.first; QFileInfo fi(fileInfo(Option::normalizePath(profile))); if (fi.exists()) { -- cgit v1.2.3