diff options
author | Christian Tismer <tismer@stackless.com> | 2020-07-08 14:26:04 +0200 |
---|---|---|
committer | Christian Tismer <tismer@stackless.com> | 2020-07-09 11:34:36 +0200 |
commit | fb2dc48389c1099bef3aaed97f16ce2bd1b90fee (patch) | |
tree | fd3266c3f422170df2b92bd494b7e49b7bcf712e /sources/shiboken2/generator | |
parent | 39c6018e484d2a6850d239de03fef89df730f357 (diff) |
shiboken: optimize method override strings
The override strings in bindingmanager were based upon
pure C strings for a long time. There was some mild overhead
of creating PyObject all the time.
With the upcoming name mangling of Selectable Features,
this becomes even a bit more inefficient when strings also get
mangled. With Python strings this is just a dict lookup.
This patch uses the same machinery as `Shiboken::PyName`.
Task-number: PYSIDE-1019
Change-Id: I4eed7222371dadeed0e9ba98cc7970e726ffc044
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'sources/shiboken2/generator')
-rw-r--r-- | sources/shiboken2/generator/shiboken2/cppgenerator.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp index d0c144358..001c6d902 100644 --- a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp +++ b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp @@ -939,9 +939,10 @@ void CppGenerator::writeVirtualMethodNative(QTextStream &s, s << INDENT << returnStatement(defaultReturnExpr.returnValue()) << Qt::endl; } - s << INDENT << "Shiboken::AutoDecRef " << PYTHON_OVERRIDE_VAR << "(Shiboken::BindingManager::instance().getOverride(this, \""; - s << funcName << "\"));\n"; - + s << INDENT << "static PyObject *pyFuncName = Shiboken::String::createStaticString(\"" + << funcName << "\");\n"; + s << INDENT << "Shiboken::AutoDecRef " << PYTHON_OVERRIDE_VAR + << "(Shiboken::BindingManager::instance().getOverride(this, pyFuncName));\n"; s << INDENT << "if (" << PYTHON_OVERRIDE_VAR << ".isNull()) {\n"; { Indentation indentation(INDENT); |