diff --git a/src/plugins/cpptools/cppmodelmanager.cpp b/src/plugins/cpptools/cppmodelmanager.cpp index a88742112e71ff4095c60cac20f787347f079834..f4be14c6b0c8ea966ba818d10745428e33a8e574 100644 --- a/src/plugins/cpptools/cppmodelmanager.cpp +++ b/src/plugins/cpptools/cppmodelmanager.cpp @@ -397,6 +397,28 @@ bool CppPreprocessor::includeFile(const QString &absoluteFilePath, QString *resu } QString CppPreprocessor::tryIncludeFile(QString &fileName, IncludeType type, unsigned *revision) +{ + if (type == IncludeGlobal) { + const QString fn = m_fileNameCache.value(fileName); + + if (! fn.isEmpty()) { + fileName = fn; + + if (revision) + *revision = 0; + + return QString(); + } + } + + const QString originalFileName = fileName; + const QString contents = tryIncludeFile_helper(fileName, type, revision); + if (type == IncludeGlobal) + m_fileNameCache.insert(originalFileName, fileName); + return contents; +} + +QString CppPreprocessor::tryIncludeFile_helper(QString &fileName, IncludeType type, unsigned *revision) { QFileInfo fileInfo(fileName); if (fileName == QLatin1String(pp_configuration_file) || fileInfo.isAbsolute()) { @@ -1375,9 +1397,6 @@ void CppModelManager::parse(QFutureInterface<void> &future, if (future.isCanceled()) break; - // Change the priority of the background parser thread to idle. - QThread::currentThread()->setPriority(QThread::IdlePriority); - const QString fileName = files.at(i); const bool isSourceFile = i < sourceCount; @@ -1396,9 +1415,6 @@ void CppModelManager::parse(QFutureInterface<void> &future, if (isSourceFile) preproc->resetEnvironment(); - - // Restore the previous thread priority. - QThread::currentThread()->setPriority(QThread::NormalPriority); } future.setProgressValue(files.size()); diff --git a/src/plugins/cpptools/cppmodelmanager.h b/src/plugins/cpptools/cppmodelmanager.h index 2e6651cb12e77b1c676a31a399145c8fd6c91271..1ba6d71efdbc2191fa74d763761b775168fc4e99 100644 --- a/src/plugins/cpptools/cppmodelmanager.h +++ b/src/plugins/cpptools/cppmodelmanager.h @@ -270,6 +270,7 @@ protected: bool includeFile(const QString &absoluteFilePath, QString *result, unsigned *revision); QString tryIncludeFile(QString &fileName, IncludeType type, unsigned *revision); + QString tryIncludeFile_helper(QString &fileName, IncludeType type, unsigned *revision); void mergeEnvironment(CPlusPlus::Document::Ptr doc); @@ -303,6 +304,7 @@ private: QSet<QString> m_todo; QSet<QString> m_processed; unsigned m_revision; + QHash<QString, QString> m_fileNameCache; }; } // namespace Internal