diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2021-04-16 08:48:52 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2021-04-20 13:54:57 +0200 |
commit | d0222d66573d6316a22b9ffce205d1f6db8046bd (patch) | |
tree | e985f8f2752f9cd3034e634f838ee3f5fa8b7b5e /sources | |
parent | 3ba32b1267ad839a5f26a7952f6054daf4e53db4 (diff) |
PySide6: Call reserve() when converting lists
If a size can be obtained, add a call to reserve()
to avoid reallocations for large lists.
Task-number: PYSIDE-1540
Task-number: PYSIDE-1503
Change-Id: I95a8a6aa02641d9f174dbc3b63740a05d1d95a45
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources')
-rw-r--r-- | sources/pyside6/PySide6/templates/core_common.xml | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/sources/pyside6/PySide6/templates/core_common.xml b/sources/pyside6/PySide6/templates/core_common.xml index b173684ba..d3bedfc9f 100644 --- a/sources/pyside6/PySide6/templates/core_common.xml +++ b/sources/pyside6/PySide6/templates/core_common.xml @@ -296,6 +296,12 @@ <template name="pyseq_to_cpplist_conversion"> // PYSIDE-795: Turn all sequences into iterables. + if (PyList_Check(%in)) { + const Py_ssize_t size = PySequence_Size(%in); + if (size > 10) + (%out).reserve(size); + } + Shiboken::AutoDecRef it(PyObject_GetIter(%in)); PyObject *(*iternext)(PyObject *) = *Py_TYPE(it)->tp_iternext; for (;;) { |