aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2023-09-27 09:29:51 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2023-09-27 15:27:42 +0000
commit6e39375b2236761e20b3826732a4b22c9b19a649 (patch)
treeb1446a6627063595ae8a4bc37167adeb40e5c334
parent845ca7bc0957645cd2841b121beb70d765542f49 (diff)
Avoid some string conversions
Remove some usages of String::toCString(func_name) and construction of a QByteArray. Change-Id: I9fb29341fba1be205e70d8d5ffc1a6d258ef87dd Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> (cherry picked from commit 9c996e666aea2c6b8854c82299ee372008f20a2d) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> (cherry picked from commit 49f33ee79172e6db7d6dc17a14e5623292a02852)
-rw-r--r--sources/pyside6/libpyside/dynamicqmetaobject.cpp5
-rw-r--r--sources/pyside6/libpyside/pyside.cpp5
-rw-r--r--sources/shiboken6/libshiboken/signature/signature.cpp2
3 files changed, 7 insertions, 5 deletions
diff --git a/sources/pyside6/libpyside/dynamicqmetaobject.cpp b/sources/pyside6/libpyside/dynamicqmetaobject.cpp
index e16f1b3e4..7b351d580 100644
--- a/sources/pyside6/libpyside/dynamicqmetaobject.cpp
+++ b/sources/pyside6/libpyside/dynamicqmetaobject.cpp
@@ -620,9 +620,10 @@ void MetaObjectBuilderPrivate::parsePythonType(PyTypeObject *type)
while (PyDict_Next(attrs, &pos, &key, &value)) {
if (Property::checkType(value)) {
- const int index = m_baseObject->indexOfProperty(String::toCString(key));
+ const QByteArray name = String::toCString(key);
+ const int index = m_baseObject->indexOfProperty(name);
if (index == -1)
- addProperty(String::toCString(key), value);
+ addProperty(name, value);
} else if (Py_TYPE(value)->tp_call != nullptr) {
// PYSIDE-198: PyFunction_Check does not work with Nuitka.
// Register slots.
diff --git a/sources/pyside6/libpyside/pyside.cpp b/sources/pyside6/libpyside/pyside.cpp
index 3fab9c8e5..60c524be0 100644
--- a/sources/pyside6/libpyside/pyside.cpp
+++ b/sources/pyside6/libpyside/pyside.cpp
@@ -469,7 +469,6 @@ const QMetaObject *retrieveMetaObject(PyObject *pyObj)
void initQObjectSubType(PyTypeObject *type, PyObject *args, PyObject * /* kwds */)
{
PyTypeObject *qObjType = Shiboken::Conversions::getPythonTypeObject("QObject*");
- QByteArray className(Shiboken::String::toCString(PyTuple_GET_ITEM(args, 0)));
PyObject *bases = PyTuple_GET_ITEM(args, 1);
int numBases = PyTuple_GET_SIZE(bases);
@@ -484,7 +483,9 @@ void initQObjectSubType(PyTypeObject *type, PyObject *args, PyObject * /* kwds *
}
}
if (!userData) {
- qWarning("Sub class of QObject not inheriting QObject!? Crash will happen when using %s.", className.constData());
+ const char *className = Shiboken::String::toCString(PyTuple_GET_ITEM(args, 0));
+ qWarning("Sub class of QObject not inheriting QObject!? Crash will happen when using %s.",
+ className);
return;
}
// PYSIDE-1463: Don't change feature selection durin subtype initialization.
diff --git a/sources/shiboken6/libshiboken/signature/signature.cpp b/sources/shiboken6/libshiboken/signature/signature.cpp
index 25bab87d4..e4780d833 100644
--- a/sources/shiboken6/libshiboken/signature/signature.cpp
+++ b/sources/shiboken6/libshiboken/signature/signature.cpp
@@ -197,7 +197,7 @@ PyObject *GetSignature_Wrapper(PyObject *ob, PyObject *modifier)
PyObject *props = PyDict_GetItem(dict, func_name);
if (props == nullptr) {
// handle `__init__` like the class itself
- if (strcmp(String::toCString(func_name), "__init__") == 0)
+ if (PyUnicode_CompareWithASCIIString(func_name, "__init__") == 0)
return GetSignature_TypeMod(objclass, modifier);
Py_RETURN_NONE;
}