Speed up construction of QString's from python unicode strings.
This commit is contained in:
parent
d2cd71313d
commit
86fa278e1c
1 changed files with 2 additions and 5 deletions
|
|
@ -27,14 +27,11 @@ inline QString Converter< QString >::toCpp(PyObject* pyobj)
|
||||||
} else if (PyQLatin1String_Check(pyobj)) {
|
} else if (PyQLatin1String_Check(pyobj)) {
|
||||||
return QString(Converter< QLatin1String >::toCpp(pyobj));
|
return QString(Converter< QLatin1String >::toCpp(pyobj));
|
||||||
} else if (PyUnicode_Check(pyobj)) {
|
} else if (PyUnicode_Check(pyobj)) {
|
||||||
#if defined(Py_UNICODE_WIDE)
|
|
||||||
Py_UNICODE* unicode = PyUnicode_AS_UNICODE(pyobj);
|
Py_UNICODE* unicode = PyUnicode_AS_UNICODE(pyobj);
|
||||||
|
#if defined(Py_UNICODE_WIDE)
|
||||||
return QString::fromUcs4(unicode);
|
return QString::fromUcs4(unicode);
|
||||||
#else
|
#else
|
||||||
PyObject* str = PyUnicode_AsUTF8String(pyobj);
|
return QString::fromUtf16(unicode, PyUnicode_GET_SIZE(pyobj));
|
||||||
QString result = QString::fromUtf8(PyString_AS_STRING(str));
|
|
||||||
Py_DECREF(str);
|
|
||||||
return result;
|
|
||||||
#endif
|
#endif
|
||||||
} else if (PyString_Check(pyobj))
|
} else if (PyString_Check(pyobj))
|
||||||
return QString(Converter< char * >::toCpp(pyobj));
|
return QString(Converter< char * >::toCpp(pyobj));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue