aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@digia.com>2014-07-28 16:31:04 +0200
committerChristian Kandeler <christian.kandeler@digia.com>2014-07-28 16:48:20 +0200
commitf185005c0ff34b2e477b2d2159e58837474fc3cc (patch)
tree7862fa4ffd75f1a01c5bec4f7664da37187def9e
parenta9350ebcb713d89bde8a9221d15aa1ead8976221 (diff)
fix speed regression
Commit 9297ea217284e2279f2d4471b3f8fc754dc5fe71 introduced a speed penalty. This is a quasi-revert of said commit. Change-Id: Ia0b0741cf818a9867f127a25830630fb3ea352ff Reviewed-by: Christian Kandeler <christian.kandeler@digia.com>
-rw-r--r--src/lib/corelib/language/moduleloader.cpp9
-rw-r--r--src/lib/corelib/language/moduleloader.h6
2 files changed, 10 insertions, 5 deletions
diff --git a/src/lib/corelib/language/moduleloader.cpp b/src/lib/corelib/language/moduleloader.cpp
index 4d22e5efd..1e2c66c9a 100644
--- a/src/lib/corelib/language/moduleloader.cpp
+++ b/src/lib/corelib/language/moduleloader.cpp
@@ -112,6 +112,7 @@ ModuleLoaderResult ModuleLoader::load(const SetupProjectParameters &parameters)
m_logger.qbsTrace() << "[MODLDR] load" << parameters.projectFilePath();
m_parameters = parameters;
m_validItemPropertyNamesPerItem.clear();
+ m_globalModuleItemCache.clear();
m_disabledItems.clear();
ModuleLoaderResult result;
@@ -866,7 +867,7 @@ Item *ModuleLoader::loadModuleFile(ProductContext *productContext, const QString
if (m_logger.traceEnabled())
m_logger.qbsTrace() << "[MODLDR] trying to load " << fullModuleName << " from " << filePath;
- const ContextBase::ModuleItemCache::key_type cacheKey(filePath, productContext->profileName);
+ const ModuleItemCache::key_type cacheKey(filePath, productContext->profileName);
Item *module = productContext->moduleItemCache.value(cacheKey);
if (module) {
m_logger.qbsTrace() << "[LDR] loadModuleFile cache hit for " << filePath;
@@ -883,7 +884,11 @@ Item *ModuleLoader::loadModuleFile(ProductContext *productContext, const QString
m_logger.qbsTrace() << "[LDR] loadModuleFile " << filePath;
*cacheHit = false;
- module = m_reader->readFile(filePath);
+ module = m_globalModuleItemCache.value(cacheKey);
+ if (!module) {
+ module = m_reader->readFile(filePath);
+ m_globalModuleItemCache.insert(cacheKey, module);
+ }
if (!isBaseModule) {
DependsContext dependsContext;
dependsContext.product = productContext;
diff --git a/src/lib/corelib/language/moduleloader.h b/src/lib/corelib/language/moduleloader.h
index 42e82046f..67bfa1e07 100644
--- a/src/lib/corelib/language/moduleloader.h
+++ b/src/lib/corelib/language/moduleloader.h
@@ -106,6 +106,8 @@ public:
static QString fullModuleName(const QStringList &moduleName);
private:
+ typedef QMap<QPair<QString, QString>, Item *> ModuleItemCache;
+
class ContextBase
{
public:
@@ -116,7 +118,6 @@ private:
Item *item;
Item *scope;
QStringList extraSearchPaths;
- typedef QMap<QPair<QString, QString>, Item *> ModuleItemCache;
ModuleItemCache moduleItemCache;
};
@@ -195,8 +196,6 @@ private:
static void overrideItemProperties(Item *item, const QString &buildConfigKey,
const QVariantMap &buildConfig);
-
-
ScriptEngine *m_engine;
ItemPool *m_pool;
Logger m_logger;
@@ -205,6 +204,7 @@ private:
Evaluator *m_evaluator;
QStringList m_moduleSearchPaths;
QMap<QString, QStringList> m_moduleDirListCache;
+ ModuleItemCache m_globalModuleItemCache;
QHash<Item *, QSet<QString> > m_validItemPropertyNamesPerItem;
QSet<Item *> m_disabledItems;
SetupProjectParameters m_parameters;