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 <oswald.buddenhagen@theqtcompany.com>
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
bb10
Marc Mutz 2016-01-28 16:09:46 +01:00
parent 14efcaa392
commit 5af12dae41
1 changed files with 5 additions and 5 deletions

View File

@ -434,10 +434,12 @@ ProStringList VcprojGenerator::collectDependencies(QMakeProject *proj, QHash<QSt
QHash<QString, ProStringList> &subdirProjectLookup,
const ProStringList &allDependencies)
{
QLinkedList<QPair<QString, ProStringList> > collectedSubdirs;
QVector<QPair<QString, ProStringList> > 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, QHash<QSt
collectedSubdirs.append(qMakePair(tmpdir.toQString(), proj->values(ProKey(tmp_proj_subdirs.at(x) + ".depends"))));
projLookup.insert(tmp_proj_subdirs.at(x).toQString(), tmpdir.toQString());
}
QLinkedListIterator<QPair<QString, ProStringList> > collectedIt(collectedSubdirs);
while (collectedIt.hasNext()) {
QPair<QString, ProStringList> subdir = collectedIt.next();
for (const auto &subdir : qAsConst(collectedSubdirs)) {
QString profile = subdir.first;
QFileInfo fi(fileInfo(Option::normalizePath(profile)));
if (fi.exists()) {