diff options
author | Daniel Teske <daniel.teske@digia.com> | 2014-09-05 16:13:21 +0200 |
---|---|---|
committer | Daniel Teske <daniel.teske@digia.com> | 2014-09-15 15:33:20 +0200 |
commit | 1b11f9b3c0affaf447b901e2c3c7c6fce46a4341 (patch) | |
tree | 0928af2f917e5dadda3b727c4a4ef5b3e3e0117f | |
parent | 0b3d05aec2330fcd36be2e8944950169fc6c7939 (diff) | |
download | qt-creator-1b11f9b3c0affaf447b901e2c3c7c6fce46a4341.tar.gz |
QmakePriFile::update: Don't call buildDir() all the time.
Instead call it once per .pro file and pass that to all .pri file parses
and other functions. This cuts down the number of calls for opening
qtproject.pro from ~3000 to ~700 and speeds up opening qtproject.pro
by roughly 3%.
Change-Id: Iffd46d4bbedc9c380f70e916dae7151495990b39
Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
-rw-r--r-- | src/plugins/qmakeprojectmanager/qmakenodes.cpp | 51 | ||||
-rw-r--r-- | src/plugins/qmakeprojectmanager/qmakenodes.h | 14 | ||||
-rw-r--r-- | src/plugins/qmakeprojectmanager/qmakeproject.cpp | 2 |
3 files changed, 35 insertions, 32 deletions
diff --git a/src/plugins/qmakeprojectmanager/qmakenodes.cpp b/src/plugins/qmakeprojectmanager/qmakenodes.cpp index 3bff19f6cc..ea85bf269f 100644 --- a/src/plugins/qmakeprojectmanager/qmakenodes.cpp +++ b/src/plugins/qmakeprojectmanager/qmakenodes.cpp @@ -587,7 +587,9 @@ QSet<Utils::FileName> QmakePriFileNode::recursiveEnumerate(const QString &folder return result; } -void QmakePriFileNode::update(ProFile *includeFileExact, QtSupport::ProFileReader *readerExact, ProFile *includeFileCumlative, QtSupport::ProFileReader *readerCumulative) +void QmakePriFileNode::update(ProFile *includeFileExact, QtSupport::ProFileReader *readerExact, + ProFile *includeFileCumlative, QtSupport::ProFileReader *readerCumulative, + const QString &buildDir) { // add project file node if (m_fileNodes.isEmpty()) @@ -651,10 +653,10 @@ void QmakePriFileNode::update(ProFile *includeFileExact, QtSupport::ProFileReade QStringList baseVPathsExact; if (includeFileExact) - baseVPathsExact = baseVPaths(readerExact, projectDir, m_qmakeProFileNode->buildDir()); + baseVPathsExact = baseVPaths(readerExact, projectDir, buildDir); QStringList baseVPathsCumulative; if (includeFileCumlative) - baseVPathsCumulative = baseVPaths(readerCumulative, projectDir, m_qmakeProFileNode->buildDir()); + baseVPathsCumulative = baseVPaths(readerCumulative, projectDir, buildDir); const QVector<QmakeNodeStaticData::FileTypeData> &fileTypes = qmakeNodeStaticData()->fileTypeData; @@ -1848,6 +1850,8 @@ void QmakeProFileNode::applyEvaluate(EvalResult evalResult, bool async) } } + QString buildDirectory = buildDir(); + SortByPath sortByPath; Utils::sort(existingProjectNodes, sortByPath); Utils::sort(newProjectFilesExact, sortByPath); @@ -1921,7 +1925,7 @@ void QmakeProFileNode::applyEvaluate(EvalResult evalResult, bool async) ProFile *fileCumlative = includeFilesCumlative.value((*existingIt)->path()); if (fileExact || fileCumlative) { QmakePriFileNode *priFileNode = static_cast<QmakePriFileNode *>(*existingIt); - priFileNode->update(fileExact, m_readerExact, fileCumlative, m_readerCumulative); + priFileNode->update(fileExact, m_readerExact, fileCumlative, m_readerCumulative, buildDirectory); priFileNode->setIncludedInExactParse(fileExact != 0 && includedInExactParse()); } else { // We always parse exactly, because we later when async parsing don't know whether @@ -1959,7 +1963,7 @@ void QmakeProFileNode::applyEvaluate(EvalResult evalResult, bool async) QmakePriFileNode *qmakePriFileNode = new QmakePriFileNode(m_project, this, nodeToAdd); qmakePriFileNode->setParentFolderNode(this); // Needed for loop detection qmakePriFileNode->setIncludedInExactParse(fileExact != 0 && includedInExactParse()); - qmakePriFileNode->update(fileExact, m_readerExact, fileCumlative, m_readerCumulative); + qmakePriFileNode->update(fileExact, m_readerExact, fileCumlative, m_readerCumulative, buildDirectory); toAdd << qmakePriFileNode; } else { QmakeProFileNode *qmakeProFileNode = new QmakeProFileNode(m_project, nodeToAdd); @@ -1986,7 +1990,7 @@ void QmakeProFileNode::applyEvaluate(EvalResult evalResult, bool async) if (!toAdd.isEmpty()) addProjectNodes(toAdd); - QmakePriFileNode::update(fileForCurrentProjectExact, m_readerExact, fileForCurrentProjectCumlative, m_readerCumulative); + QmakePriFileNode::update(fileForCurrentProjectExact, m_readerExact, fileForCurrentProjectCumlative, m_readerCumulative, buildDirectory); m_validParse = (evalResult == EvalOk); if (m_validParse) { @@ -2025,18 +2029,17 @@ void QmakeProFileNode::applyEvaluate(EvalResult evalResult, bool async) } // update TargetInformation - m_qmakeTargetInformation = targetInformation(m_readerExact, readerBuildPass); + m_qmakeTargetInformation = targetInformation(m_readerExact, readerBuildPass, buildDirectory); m_resolvedMkspecPath = m_readerExact->resolvedMkSpec(); m_subProjectsNotToDeploy = subProjectsNotToDeploy; setupInstallsList(readerBuildPass); - QString buildDirectory = buildDir(); // update other variables QHash<QmakeVariable, QStringList> newVarValues; newVarValues[DefinesVar] = m_readerExact->values(QLatin1String("DEFINES")); - newVarValues[IncludePathVar] = includePaths(m_readerExact); + newVarValues[IncludePathVar] = includePaths(m_readerExact, buildDirectory); newVarValues[CppFlagsVar] = m_readerExact->values(QLatin1String("QMAKE_CXXFLAGS")); newVarValues[CppHeaderVar] = fileListForVar(m_readerExact, m_readerCumulative, QLatin1String("HEADERS"), m_projectDir, buildDirectory); @@ -2046,8 +2049,8 @@ void QmakeProFileNode::applyEvaluate(EvalResult evalResult, bool async) QLatin1String("OBJECTIVE_SOURCES"), m_projectDir, buildDirectory); newVarValues[ObjCHeaderVar] = fileListForVar(m_readerExact, m_readerCumulative, QLatin1String("OBJECTIVE_HEADERS"), m_projectDir, buildDirectory); - newVarValues[UiDirVar] = QStringList() << uiDirPath(m_readerExact); - newVarValues[MocDirVar] = QStringList() << mocDirPath(m_readerExact); + newVarValues[UiDirVar] = QStringList() << uiDirPath(m_readerExact, buildDirectory); + newVarValues[MocDirVar] = QStringList() << mocDirPath(m_readerExact, buildDirectory); newVarValues[ResourceVar] = fileListForVar(m_readerExact, m_readerCumulative, QLatin1String("RESOURCES"), m_projectDir, buildDirectory); newVarValues[ExactResourceVar] = fileListForVar(m_readerExact, 0, @@ -2104,7 +2107,7 @@ void QmakeProFileNode::applyEvaluate(EvalResult evalResult, bool async) setParseInProgress(false); - updateUiFiles(); + updateUiFiles(buildDirectory); m_project->destroyProFileReader(m_readerExact); m_project->destroyProFileReader(m_readerCumulative); @@ -2136,23 +2139,23 @@ QStringList QmakeProFileNode::fileListForVar(QtSupport::ProFileReader *readerExa return result; } -QString QmakeProFileNode::uiDirPath(QtSupport::ProFileReader *reader) const +QString QmakeProFileNode::uiDirPath(QtSupport::ProFileReader *reader, const QString &buildDir) const { QString path = reader->value(QLatin1String("UI_DIR")); if (QFileInfo(path).isRelative()) - path = QDir::cleanPath(buildDir() + QLatin1Char('/') + path); + path = QDir::cleanPath(buildDir + QLatin1Char('/') + path); return path; } -QString QmakeProFileNode::mocDirPath(QtSupport::ProFileReader *reader) const +QString QmakeProFileNode::mocDirPath(QtSupport::ProFileReader *reader, const QString &buildDir) const { QString path = reader->value(QLatin1String("MOC_DIR")); if (QFileInfo(path).isRelative()) - path = QDir::cleanPath(buildDir() + QLatin1Char('/') + path); + path = QDir::cleanPath(buildDir + QLatin1Char('/') + path); return path; } -QStringList QmakeProFileNode::includePaths(QtSupport::ProFileReader *reader) const +QStringList QmakeProFileNode::includePaths(QtSupport::ProFileReader *reader, const QString &buildDir) const { QStringList paths; foreach (const QString &cxxflags, m_readerExact->values(QLatin1String("QMAKE_CXXFLAGS"))) { @@ -2165,7 +2168,7 @@ QStringList QmakeProFileNode::includePaths(QtSupport::ProFileReader *reader) con // paths already contains moc dir and ui dir, due to corrrectly parsing uic.prf and moc.prf // except if those directories don't exist at the time of parsing // thus we add those directories manually (without checking for existence) - paths << mocDirPath(reader) << uiDirPath(reader); + paths << mocDirPath(reader, buildDir) << uiDirPath(reader, buildDir); // qmake always adds "." paths << m_projectDir; paths.removeDuplicates(); @@ -2236,7 +2239,7 @@ QStringList QmakeProFileNode::subDirsPaths(QtSupport::ProFileReader *reader, QSt return subProjectPaths; } -TargetInformation QmakeProFileNode::targetInformation(QtSupport::ProFileReader *reader, QtSupport::ProFileReader *readerBuildPass) const +TargetInformation QmakeProFileNode::targetInformation(QtSupport::ProFileReader *reader, QtSupport::ProFileReader *readerBuildPass, const QString &buildDir) const { TargetInformation result; if (!reader || !readerBuildPass) @@ -2249,7 +2252,7 @@ TargetInformation QmakeProFileNode::targetInformation(QtSupport::ProFileReader * } // BUILD DIR - result.buildDir = buildDir(); + result.buildDir = buildDir; if (readerBuildPass->contains(QLatin1String("DESTDIR"))) result.destDir = readerBuildPass->value(QLatin1String("DESTDIR")); @@ -2338,12 +2341,12 @@ QString QmakeProFileNode::buildDir(QmakeBuildConfiguration *bc) const return QDir::cleanPath(QDir(bc->buildDirectory().toString()).absoluteFilePath(relativeDir)); } -QString QmakeProFileNode::uiDirectory() const +QString QmakeProFileNode::uiDirectory(const QString &buildDir) const { const QmakeVariablesHash::const_iterator it = m_varValues.constFind(UiDirVar); if (it != m_varValues.constEnd() && !it.value().isEmpty()) return it.value().front(); - return buildDir(); + return buildDir; } QString QmakeProFileNode::uiHeaderFile(const QString &uiDir, const QString &formFile) @@ -2355,7 +2358,7 @@ QString QmakeProFileNode::uiHeaderFile(const QString &uiDir, const QString &form return QDir::cleanPath(uiHeaderFilePath); } -void QmakeProFileNode::updateUiFiles() +void QmakeProFileNode::updateUiFiles(const QString &buildDir) { m_uiFiles.clear(); @@ -2367,7 +2370,7 @@ void QmakeProFileNode::updateUiFiles() const QList<ProjectExplorer::FileNode*> uiFiles = uiFilesVisitor.uiFileNodes; // Find the UiDir, there can only ever be one - const QString uiDir = uiDirectory(); + const QString uiDir = uiDirectory(buildDir); foreach (const ProjectExplorer::FileNode *uiFile, uiFiles) m_uiFiles.insert(uiFile->path(), uiHeaderFile(uiDir, uiFile->path())); } diff --git a/src/plugins/qmakeprojectmanager/qmakenodes.h b/src/plugins/qmakeprojectmanager/qmakenodes.h index ff311b66df..bd47bbdf56 100644 --- a/src/plugins/qmakeprojectmanager/qmakenodes.h +++ b/src/plugins/qmakeprojectmanager/qmakenodes.h @@ -142,7 +142,7 @@ public: QmakePriFileNode(QmakeProject *project, QmakeProFileNode *qmakeProFileNode, const QString &filePath); ~QmakePriFileNode(); - void update(ProFile *includeFileExact, QtSupport::ProFileReader *readerExact, ProFile *includeFileCumlative, QtSupport::ProFileReader *readerCumalative); + void update(ProFile *includeFileExact, QtSupport::ProFileReader *readerExact, ProFile *includeFileCumlative, QtSupport::ProFileReader *readerCumalative, const QString &buildDir); // ProjectNode interface @@ -385,7 +385,7 @@ public: QString sourceDir() const; QString buildDir(QmakeBuildConfiguration *bc = 0) const; - QString uiDirectory() const; + QString uiDirectory(const QString &buildDir) const; static QString uiHeaderFile(const QString &uiDir, const QString &formFile); QHash<QString, QString> uiFiles() const; @@ -432,17 +432,17 @@ private: typedef QHash<QmakeVariable, QStringList> QmakeVariablesHash; - void updateUiFiles(); + void updateUiFiles(const QString &buildDir); QStringList fileListForVar(QtSupport::ProFileReader *readerExact, QtSupport::ProFileReader *readerCumulative, const QString &varName, const QString &projectDir, const QString &buildDir) const; - QString uiDirPath(QtSupport::ProFileReader *reader) const; - QString mocDirPath(QtSupport::ProFileReader *reader) const; - QStringList includePaths(QtSupport::ProFileReader *reader) const; + QString uiDirPath(QtSupport::ProFileReader *reader, const QString &buildDir) const; + QString mocDirPath(QtSupport::ProFileReader *reader, const QString &buildDir) const; + QStringList includePaths(QtSupport::ProFileReader *reader, const QString &buildDir) const; QStringList libDirectories(QtSupport::ProFileReader *reader) const; QStringList subDirsPaths(QtSupport::ProFileReader *reader, QStringList *subProjectsNotToDeploy, bool silent) const; - TargetInformation targetInformation(QtSupport::ProFileReader *reader, QtSupport::ProFileReader *readerBuildPass) const; + TargetInformation targetInformation(QtSupport::ProFileReader *reader, QtSupport::ProFileReader *readerBuildPass, const QString &buildDir) const; void setupInstallsList(const QtSupport::ProFileReader *reader); bool m_isDeployable; diff --git a/src/plugins/qmakeprojectmanager/qmakeproject.cpp b/src/plugins/qmakeprojectmanager/qmakeproject.cpp index 6afc4a3be8..5c97ac9721 100644 --- a/src/plugins/qmakeprojectmanager/qmakeproject.cpp +++ b/src/plugins/qmakeprojectmanager/qmakeproject.cpp @@ -976,7 +976,7 @@ QString QmakeProject::generatedUiHeader(const QString &formFile) const // the top-level project only. if (m_rootProjectNode) if (const QmakeProFileNode *pro = proFileNodeOf(m_rootProjectNode, FormType, formFile)) - return QmakeProFileNode::uiHeaderFile(pro->uiDirectory(), formFile); + return QmakeProFileNode::uiHeaderFile(pro->uiDirectory(pro->buildDir()), formFile); return QString(); } |