mirror of
https://github.com/python/cpython.git
synced 2025-11-08 17:41:42 +00:00
Simplify unicode_resizable(): singletons reference count is at least 2
This commit is contained in:
parent
8619cd7376
commit
77bb47b312
1 changed files with 7 additions and 13 deletions
|
|
@ -1257,26 +1257,20 @@ unicode_dealloc(register PyUnicodeObject *unicode)
|
||||||
static int
|
static int
|
||||||
unicode_resizable(PyObject *unicode)
|
unicode_resizable(PyObject *unicode)
|
||||||
{
|
{
|
||||||
Py_ssize_t len;
|
|
||||||
if (Py_REFCNT(unicode) != 1)
|
if (Py_REFCNT(unicode) != 1)
|
||||||
return 0;
|
return 0;
|
||||||
if (PyUnicode_CHECK_INTERNED(unicode))
|
if (PyUnicode_CHECK_INTERNED(unicode))
|
||||||
return 0;
|
return 0;
|
||||||
if (unicode == unicode_empty)
|
assert (unicode != unicode_empty);
|
||||||
return 0;
|
#ifdef Py_DEBUG
|
||||||
if (_PyUnicode_KIND(unicode) == PyUnicode_WCHAR_KIND)
|
if (_PyUnicode_KIND(unicode) != PyUnicode_WCHAR_KIND
|
||||||
len = PyUnicode_WSTR_LENGTH(unicode);
|
&& PyUnicode_GET_LENGTH(unicode) == 1)
|
||||||
else
|
{
|
||||||
len = PyUnicode_GET_LENGTH(unicode);
|
Py_UCS4 ch = PyUnicode_READ_CHAR(unicode, 0);
|
||||||
if (len == 1) {
|
|
||||||
Py_UCS4 ch;
|
|
||||||
if (_PyUnicode_KIND(unicode) == PyUnicode_WCHAR_KIND)
|
|
||||||
ch = _PyUnicode_WSTR(unicode)[0];
|
|
||||||
else
|
|
||||||
ch = PyUnicode_READ_CHAR(unicode, 0);
|
|
||||||
if (ch < 256 && unicode_latin1[ch] == unicode)
|
if (ch < 256 && unicode_latin1[ch] == unicode)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue