aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/corelib/buildgraph/depscanner.cpp
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@qt.io>2017-11-20 16:00:03 +0100
committerChristian Kandeler <christian.kandeler@qt.io>2017-11-23 10:31:32 +0000
commit846b4ece2a8dcb6b407edbf9d0b23095e15f4566 (patch)
tree8409603af9a27243d388729b8e3b3014a9481b28 /src/lib/corelib/buildgraph/depscanner.cpp
parente9b79f0d5165dc71dac10ed76b5fa06508672605 (diff)
Share ScriptFunction objects between products
The source code of script functions does not differ among module instantiations, so there's no need to give each product its own copy. For example, resolving the QtCreator super project now allocates about 80 of these objects, rather than 16000, each of which had their own unshared copy of the script source code. Change-Id: I10d67991ce170826346d434fe58ea6608fa18a1f Reviewed-by: Jake Petroules <jake.petroules@qt.io>
Diffstat (limited to 'src/lib/corelib/buildgraph/depscanner.cpp')
-rw-r--r--src/lib/corelib/buildgraph/depscanner.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/lib/corelib/buildgraph/depscanner.cpp b/src/lib/corelib/buildgraph/depscanner.cpp
index 8b5a0a0fe..9af8109b3 100644
--- a/src/lib/corelib/buildgraph/depscanner.cpp
+++ b/src/lib/corelib/buildgraph/depscanner.cpp
@@ -161,7 +161,7 @@ UserDependencyScanner::UserDependencyScanner(const ResolvedScannerConstPtr &scan
{
m_global = m_engine->newObject();
m_global.setPrototype(m_engine->globalObject());
- setupScriptEngineForFile(m_engine, m_scanner->scanScript->fileContext, m_global,
+ setupScriptEngineForFile(m_engine, m_scanner->scanScript.fileContext(), m_global,
ObserveMode::Disabled); // TODO: QBS-1092
}
@@ -192,7 +192,7 @@ const void *UserDependencyScanner::key() const
QString UserDependencyScanner::createId() const
{
- return m_scanner->scanScript->sourceCode;
+ return m_scanner->scanScript.sourceCode();
}
bool UserDependencyScanner::areModulePropertiesCompatible(const PropertyMapConstPtr &m1,
@@ -220,7 +220,7 @@ public:
}
};
-QStringList UserDependencyScanner::evaluate(Artifact *artifact, const ScriptFunctionPtr &script)
+QStringList UserDependencyScanner::evaluate(Artifact *artifact, const PrivateScriptFunction &script)
{
ScriptEngineActiveFlagGuard guard(m_engine);
@@ -237,18 +237,18 @@ QStringList UserDependencyScanner::evaluate(Artifact *artifact, const ScriptFunc
args.push_back(Transformer::translateFileConfig(m_engine, artifact, m_scanner->module->name));
m_engine->setGlobalObject(m_global);
- QScriptValue &function = script->scriptFunction;
+ QScriptValue &function = script.scriptFunction;
if (!function.isValid() || function.engine() != m_engine) {
- function = m_engine->evaluate(script->sourceCode);
+ function = m_engine->evaluate(script.sourceCode());
if (Q_UNLIKELY(!function.isFunction()))
- throw ErrorInfo(Tr::tr("Invalid scan script."), script->location);
+ throw ErrorInfo(Tr::tr("Invalid scan script."), script.location());
}
QScriptValue result = function.call(QScriptValue(), args);
m_engine->setGlobalObject(m_global.prototype());
m_engine->clearRequestedProperties();
if (Q_UNLIKELY(m_engine->hasErrorOrException(result))) {
QString msg = Tr::tr("evaluating scan script: ") + m_engine->lastErrorString(result);
- const CodeLocation loc = m_engine->lastErrorLocation(result, script->location);
+ const CodeLocation loc = m_engine->lastErrorLocation(result, script.location());
m_engine->clearExceptions();
throw ErrorInfo(msg, loc);
}