aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2022-06-27 11:35:09 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-06-27 13:19:49 +0000
commitffff7755e361a7462dbeecb8f2879d7eaf7b7805 (patch)
treefddf1d9a0cc6b849c4bcdb1b5189e60a7e9c900d
parent9683149520c0f8159ca907f8614421971d9fc248 (diff)
libshiboken: Remove old code paths for static strings
PyUnicode_InternFromString() should be used unconditionally. Amends a09a1db8391243e6bb290ee66bb6e3afbb114c61. Task-number: PYSIDE-1960 Change-Id: I80837b2b58c9eadbd2aca4279df10e2f03e30450 Reviewed-by: Christian Tismer <tismer@stackless.com> (cherry picked from commit 71d97ff54ba2ea225d4fb215b3dbbf7feeab489a) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--sources/shiboken6/libshiboken/sbkstring.cpp59
1 files changed, 0 insertions, 59 deletions
diff --git a/sources/shiboken6/libshiboken/sbkstring.cpp b/sources/shiboken6/libshiboken/sbkstring.cpp
index 3c888f7c6..aa96d01e4 100644
--- a/sources/shiboken6/libshiboken/sbkstring.cpp
+++ b/sources/shiboken6/libshiboken/sbkstring.cpp
@@ -41,15 +41,6 @@
#include "sbkstaticstrings_p.h"
#include "autodecref.h"
-#if PY_VERSION_HEX >= 0x030B0000 || defined(Py_LIMITED_API)
-# define USE_INTERN_STRINGS
-#endif
-
-#ifndef USE_INTERN_STRINGS
-# include <vector>
-# include <unordered_set>
-#endif
-
namespace Shiboken::String
{
@@ -221,60 +212,10 @@ Py_ssize_t len(PyObject *str)
// PyObject *attr = PyObject_GetAttr(obj, name());
//
-#ifdef USE_INTERN_STRINGS
PyObject *createStaticString(const char *str)
{
return PyUnicode_InternFromString(str);
}
-#else
-
-using StaticStrings = std::unordered_set<PyObject *>;
-
-static void finalizeStaticStrings(); // forward
-
-static StaticStrings &staticStrings()
-{
- static StaticStrings result;
- return result;
-}
-
-static void finalizeStaticStrings()
-{
- auto &set = staticStrings();
- for (PyObject *ob : set) {
- Py_SET_REFCNT(ob, 1);
- Py_DECREF(ob);
- }
- set.clear();
-}
-
-PyObject *createStaticString(const char *str)
-{
- static bool initialized = false;
- if (!initialized) {
- Py_AtExit(finalizeStaticStrings);
- initialized = true;
- }
- PyObject *result = PyUnicode_InternFromString(str);
- if (result == nullptr) {
- // This error is never checked, but also very unlikely. Report and exit.
- PyErr_Print();
- Py_FatalError("unexpected error in createStaticString()");
- }
- auto it = staticStrings().find(result);
- if (it == staticStrings().end())
- staticStrings().insert(result);
- /*
- * Note: We always add one reference even if we have a new string.
- * This makes the strings immortal, and we are safe if someone
- * uses AutoDecRef, although the set cannot cope with deletions.
- * The exit handler cleans that up, anyway.
- */
- Py_INCREF(result);
- return result;
-}
-
-#endif // !USE_INTERN_STRINGS
///////////////////////////////////////////////////////////////////////
//