diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2019-04-26 09:31:48 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2019-04-30 11:51:32 +0000 |
commit | e83e07dd9fba3a2c69afe07cbee70346a1ee6ec8 (patch) | |
tree | 7c8287ba6a5270d08538180a70f5b24511cbc0d6 /sources/shiboken2/generator/shiboken2/cppgenerator.cpp | |
parent | f332f2e8e66a5fa67b302893a13f0be3687ccc38 (diff) |
shiboken/Generators: Cache class information lists per class
The function ShibokenGenerator::getFunctionGroups(class) is called
many times for each function during code generation and causes a
slowdown for the OpenGL version function classes, which have 1000
member functions.
Split away getGlobalFunctionGroups() for the case scope=0 and
introduce a global-static cache for class information that is more
involved to determine for use by the various generators.
Speeds up the generation of the QtGui module including the OpenGL
version functions from 420s to 90s.
Task-number: PYSIDE-955
Change-Id: I6b6aa35ef2197aa9cddbf339db9eb0220932f361
Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/shiboken2/generator/shiboken2/cppgenerator.cpp')
-rw-r--r-- | sources/shiboken2/generator/shiboken2/cppgenerator.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp index 29220c739..67f8f1a7b 100644 --- a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp +++ b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp @@ -453,8 +453,8 @@ void CppGenerator::generateClass(QTextStream &s, GeneratorContext &classContext) s << endl << "// Target ---------------------------------------------------------" << endl << endl; s << "extern \"C\" {" << endl; - const FunctionGroupMap &functionGroups = getFunctionGroups(metaClass); - for (FunctionGroupMapIt it = functionGroups.cbegin(), end = functionGroups.cend(); it != end; ++it) { + const auto &functionGroups = getFunctionGroups(metaClass); + for (auto it = functionGroups.cbegin(), end = functionGroups.cend(); it != end; ++it) { AbstractMetaFunctionList overloads; QSet<QString> seenSignatures; bool staticEncountered = false; @@ -5404,8 +5404,8 @@ bool CppGenerator::finishGeneration() Indentation indent(INDENT); - const FunctionGroupMap &functionGroups = getFunctionGroups(); - for (FunctionGroupMapIt it = functionGroups.cbegin(), end = functionGroups.cend(); it != end; ++it) { + const auto functionGroups = getGlobalFunctionGroups(); + for (auto it = functionGroups.cbegin(), end = functionGroups.cend(); it != end; ++it) { AbstractMetaFunctionList overloads; for (AbstractMetaFunction *func : it.value()) { if (!func->isModifiedRemoved()) { @@ -5824,7 +5824,10 @@ bool CppGenerator::writeParentChildManagement(QTextStream& s, const AbstractMeta const int numArgs = func->arguments().count(); bool ctorHeuristicEnabled = func->isConstructor() && useCtorHeuristic() && useHeuristicPolicy; - bool usePyArgs = pythonFunctionWrapperUsesListOfArguments(OverloadData(getFunctionGroups(func->implementingClass())[func->name()], this)); + const auto &groups = func->implementingClass() + ? getFunctionGroups(func->implementingClass()) + : getGlobalFunctionGroups(); + bool usePyArgs = pythonFunctionWrapperUsesListOfArguments(OverloadData(groups[func->name()], this)); ArgumentOwner argOwner = getArgumentOwner(func, argIndex); ArgumentOwner::Action action = argOwner.action; |