GH-96458: Statically initialize utf8 representation of static strings (#96481)

This commit is contained in:
Kumar Aditya 2022-09-03 12:13:08 +05:30 committed by GitHub
parent 16c6759b37
commit 6dab8c95bd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 139 additions and 165 deletions

View file

@ -15184,23 +15184,6 @@ _PyUnicode_FiniTypes(PyInterpreterState *interp)
}
static void unicode_static_dealloc(PyObject *op)
{
PyASCIIObject *ascii = _PyASCIIObject_CAST(op);
assert(ascii->state.compact);
if (!ascii->state.ascii) {
PyCompactUnicodeObject* compact = (PyCompactUnicodeObject*)op;
if (compact->utf8) {
PyObject_Free(compact->utf8);
compact->utf8 = NULL;
compact->utf8_length = 0;
}
}
}
void
_PyUnicode_Fini(PyInterpreterState *interp)
{
@ -15217,24 +15200,8 @@ _PyUnicode_Fini(PyInterpreterState *interp)
_PyUnicode_FiniEncodings(&state->fs_codec);
unicode_clear_identifiers(state);
// Clear the single character singletons
for (int i = 0; i < 128; i++) {
unicode_static_dealloc((PyObject*)&_Py_SINGLETON(strings).ascii[i]);
}
for (int i = 0; i < 128; i++) {
unicode_static_dealloc((PyObject*)&_Py_SINGLETON(strings).latin1[i]);
}
}
void
_PyStaticUnicode_Dealloc(PyObject *op)
{
unicode_static_dealloc(op);
}
/* A _string module, to export formatter_parser and formatter_field_name_split
to the string.Formatter class implemented in Python. */