summaryrefslogtreecommitdiffstats
path: root/Objects/unicodeobject.c
diff options
context:
space:
mode:
authorEric Snow <ericsnowcurrently@gmail.com>2022-11-16 16:37:14 (GMT)
committerGitHub <noreply@github.com>2022-11-16 16:37:14 (GMT)
commit5f55067e238c21de25f09ece9bb24ae8c42d02b4 (patch)
treef3fbce5e16aaa3a8871518c4ccb18bc8a1d86e9e /Objects/unicodeobject.c
parent5cfb7d19f5242c9b8ffd2fe30a24569e85a99e1d (diff)
downloadcpython-5f55067e238c21de25f09ece9bb24ae8c42d02b4.zip
cpython-5f55067e238c21de25f09ece9bb24ae8c42d02b4.tar.gz
cpython-5f55067e238c21de25f09ece9bb24ae8c42d02b4.tar.bz2
gh-81057: Move More Globals in Core Code to _PyRuntimeState (gh-99516)
https://github.com/python/cpython/issues/81057
Diffstat (limited to 'Objects/unicodeobject.c')
-rw-r--r--Objects/unicodeobject.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index eaa8f58..b1acfc7 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -1856,7 +1856,7 @@ _PyUnicode_FromId(_Py_Identifier *id)
Py_ssize_t index = _Py_atomic_size_get(&id->index);
if (index < 0) {
- struct _Py_unicode_runtime_ids *rt_ids = &interp->runtime->unicode_ids;
+ struct _Py_unicode_runtime_ids *rt_ids = &interp->runtime->unicode_state.ids;
PyThread_acquire_lock(rt_ids->lock, WAIT_LOCK);
// Check again to detect concurrent access. Another thread can have
@@ -14491,12 +14491,14 @@ PyTypeObject PyUnicode_Type = {
/* Initialize the Unicode implementation */
-void
-_PyUnicode_InitState(PyInterpreterState *interp)
+static void
+_init_global_state(void)
{
- if (!_Py_IsMainInterpreter(interp)) {
+ static int initialized = 0;
+ if (initialized) {
return;
}
+ initialized = 1;
/* initialize the linebreak bloom filter */
const Py_UCS2 linebreak[] = {
@@ -14514,6 +14516,15 @@ _PyUnicode_InitState(PyInterpreterState *interp)
Py_ARRAY_LENGTH(linebreak));
}
+void
+_PyUnicode_InitState(PyInterpreterState *interp)
+{
+ if (!_Py_IsMainInterpreter(interp)) {
+ return;
+ }
+ _init_global_state();
+}
+
PyStatus
_PyUnicode_InitGlobalObjects(PyInterpreterState *interp)