diff options
author | Christian Kandeler <christian.kandeler@digia.com> | 2014-07-29 09:36:00 +0200 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@digia.com> | 2014-07-29 11:41:43 +0200 |
commit | 472a0e505a78fddf5d7ce02b2c6ef8f859926b3e (patch) | |
tree | dee1e65bfff43b9a5106e3fd7673d1c888013547 /src | |
parent | 472619b8254a0c29611a8d3673a7dac9bc0eebf1 (diff) |
Clean up module item caches.
The product- and project-specific ones were left-overs from earlier
concepts, so get rid of them. Everything goes into the same "global"
cache now. Also make sure that we cache disabled modules too; the
respective files were always re-read from disk so far.
Change-Id: Ib1dee08dbbfe61b0369772df96122e8eab19741b
Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/corelib/language/moduleloader.cpp | 28 | ||||
-rw-r--r-- | src/lib/corelib/language/moduleloader.h | 12 |
2 files changed, 16 insertions, 24 deletions
diff --git a/src/lib/corelib/language/moduleloader.cpp b/src/lib/corelib/language/moduleloader.cpp index 1e2c66c9a..52f1978d3 100644 --- a/src/lib/corelib/language/moduleloader.cpp +++ b/src/lib/corelib/language/moduleloader.cpp @@ -112,7 +112,7 @@ ModuleLoaderResult ModuleLoader::load(const SetupProjectParameters ¶meters) m_logger.qbsTrace() << "[MODLDR] load" << parameters.projectFilePath(); m_parameters = parameters; m_validItemPropertyNamesPerItem.clear(); - m_globalModuleItemCache.clear(); + m_modulePrototypeItemCache.clear(); m_disabledItems.clear(); ModuleLoaderResult result; @@ -868,27 +868,14 @@ Item *ModuleLoader::loadModuleFile(ProductContext *productContext, const QString m_logger.qbsTrace() << "[MODLDR] trying to load " << fullModuleName << " from " << filePath; const ModuleItemCache::key_type cacheKey(filePath, productContext->profileName); - Item *module = productContext->moduleItemCache.value(cacheKey); - if (module) { + const ItemCacheValue cacheValue = m_modulePrototypeItemCache.value(cacheKey); + if (cacheValue.module) { m_logger.qbsTrace() << "[LDR] loadModuleFile cache hit for " << filePath; *cacheHit = true; - return module; - } - - module = productContext->project->moduleItemCache.value(cacheKey); - if (module) { - m_logger.qbsTrace() << "[LDR] loadModuleFile returns clone for " << filePath; - *cacheHit = true; - return module->clone(m_pool); + return cacheValue.enabled ? cacheValue.module : 0; } - - m_logger.qbsTrace() << "[LDR] loadModuleFile " << filePath; *cacheHit = false; - module = m_globalModuleItemCache.value(cacheKey); - if (!module) { - module = m_reader->readFile(filePath); - m_globalModuleItemCache.insert(cacheKey, module); - } + Item * const module = m_reader->readFile(filePath); if (!isBaseModule) { DependsContext dependsContext; dependsContext.product = productContext; @@ -897,6 +884,7 @@ Item *ModuleLoader::loadModuleFile(ProductContext *productContext, const QString } if (!checkItemCondition(module)) { m_logger.qbsTrace() << "[LDR] module condition is false"; + m_modulePrototypeItemCache.insert(cacheKey, ItemCacheValue(module, false)); return 0; } @@ -914,9 +902,7 @@ Item *ModuleLoader::loadModuleFile(ProductContext *productContext, const QString module->setProperty(vmit.key(), v); } - productContext->moduleItemCache.insert(cacheKey, module); - productContext->project->moduleItemCache.insert(cacheKey, module); - + m_modulePrototypeItemCache.insert(cacheKey, ItemCacheValue(module, true)); return module; } diff --git a/src/lib/corelib/language/moduleloader.h b/src/lib/corelib/language/moduleloader.h index 67bfa1e07..07e0ab24f 100644 --- a/src/lib/corelib/language/moduleloader.h +++ b/src/lib/corelib/language/moduleloader.h @@ -106,7 +106,14 @@ public: static QString fullModuleName(const QStringList &moduleName); private: - typedef QMap<QPair<QString, QString>, Item *> ModuleItemCache; + struct ItemCacheValue { + explicit ItemCacheValue(Item *module = 0, bool enabled = false) + : module(module), enabled(enabled) {} + Item *module; + bool enabled; + }; + + typedef QMap<QPair<QString, QString>, ItemCacheValue> ModuleItemCache; class ContextBase { @@ -118,7 +125,6 @@ private: Item *item; Item *scope; QStringList extraSearchPaths; - ModuleItemCache moduleItemCache; }; class ProjectContext : public ContextBase @@ -204,7 +210,7 @@ private: Evaluator *m_evaluator; QStringList m_moduleSearchPaths; QMap<QString, QStringList> m_moduleDirListCache; - ModuleItemCache m_globalModuleItemCache; + ModuleItemCache m_modulePrototypeItemCache; QHash<Item *, QSet<QString> > m_validItemPropertyNamesPerItem; QSet<Item *> m_disabledItems; SetupProjectParameters m_parameters; |