aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorIvan Komissarov <abbapoh@gmail.com>2020-02-23 21:52:04 +0100
committerIvan Komissarov <ABBAPOH@gmail.com>2020-02-26 14:00:38 +0000
commit6e6510d47d61cd8b26f77b6cc83eb98acf0d2e44 (patch)
treef6ac671b2bca73cad0115382ffd546bf3eb67cca /src
parent5d12dfe300a2ad984c36af47107380109a06c16e (diff)
Do not call isFileCaseCorrect that often
'qbs resolve qtcreator.qbs' results: macOs: 0m31.510s -> 0m26.417s Change-Id: Ibd69ba87f5515e99776e6af2f87587e711213b41 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/lib/corelib/language/moduleloader.cpp17
-rw-r--r--src/lib/corelib/language/moduleloader.h4
2 files changed, 16 insertions, 5 deletions
diff --git a/src/lib/corelib/language/moduleloader.cpp b/src/lib/corelib/language/moduleloader.cpp
index 4f00a634c..9f3a3a53e 100644
--- a/src/lib/corelib/language/moduleloader.cpp
+++ b/src/lib/corelib/language/moduleloader.cpp
@@ -3760,12 +3760,23 @@ QString ModuleLoader::findExistingModulePath(const QString &searchPath,
const QualifiedId &moduleName)
{
QString dirPath = searchPath + QStringLiteral("/modules");
+
+ // isFileCaseCorrect is a very expensive call on macOS, so we cache the value for the
+ // modules and search paths we've already processed
+ auto &moduleInfo = m_existingModulePathCache[{searchPath, moduleName}];
+ if (moduleInfo.first) // poor man's std::optional<QString>
+ return moduleInfo.second;
+
for (const QString &moduleNamePart : moduleName) {
dirPath = FileInfo::resolvePath(dirPath, moduleNamePart);
- if (!FileInfo::exists(dirPath) || !FileInfo::isFileCaseCorrect(dirPath))
- return {};
+ if (!FileInfo::exists(dirPath) || !FileInfo::isFileCaseCorrect(dirPath)) {
+ moduleInfo.first = true;
+ return moduleInfo.second = QString();
+ }
}
- return dirPath;
+
+ moduleInfo.first = true;
+ return moduleInfo.second = dirPath;
}
QVariantMap ModuleLoader::moduleProviderConfig(ModuleLoader::ProductContext &product)
diff --git a/src/lib/corelib/language/moduleloader.h b/src/lib/corelib/language/moduleloader.h
index 204c93ed4..410b2dde2 100644
--- a/src/lib/corelib/language/moduleloader.h
+++ b/src/lib/corelib/language/moduleloader.h
@@ -338,8 +338,7 @@ private:
QStringList readExtraSearchPaths(Item *item, bool *wasSet = nullptr);
void copyProperties(const Item *sourceProject, Item *targetProject);
Item *wrapInProjectIfNecessary(Item *item);
- static QString findExistingModulePath(const QString &searchPath,
- const QualifiedId &moduleName);
+ QString findExistingModulePath(const QString &searchPath, const QualifiedId &moduleName);
enum class ModuleProviderLookup { Regular, Fallback };
struct ModuleProviderResult
@@ -412,6 +411,7 @@ private:
ItemReader *m_reader;
Evaluator *m_evaluator;
QMap<QString, QStringList> m_moduleDirListCache;
+ QHash<std::pair<QString, QualifiedId>, std::pair<bool, QString>> m_existingModulePathCache;
// The keys are file paths, the values are module prototype items accompanied by a profile.
std::unordered_map<QString, std::vector<std::pair<Item *, QString>>> m_modulePrototypes;