mirror of https://github.com/python/cpython.git
bpo-45061: Revert unicode_is_singleton() change (GH-28516)
Don't use a loop over 256 items, only checks for a single singleton.
This commit is contained in:
parent
8f943ca257
commit
8620be99da
|
@ -1994,8 +1994,10 @@ unicode_is_singleton(PyObject *unicode)
|
||||||
if (unicode == state->empty_string) {
|
if (unicode == state->empty_string) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
for (Py_ssize_t i = 0; i < 256; i++) {
|
PyASCIIObject *ascii = (PyASCIIObject *)unicode;
|
||||||
if (unicode == state->latin1[i]) {
|
if (ascii->state.kind != PyUnicode_WCHAR_KIND && ascii->length == 1) {
|
||||||
|
Py_UCS4 ch = PyUnicode_READ_CHAR(unicode, 0);
|
||||||
|
if (ch < 256 && state->latin1[ch] == unicode) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue