Issue #28701: Replace PyUnicode_CompareWithASCIIString with _PyUnicode_EqualToASCIIString.

The latter function is more readable, faster and doesn't raise exceptions.
This commit is contained in:
Serhiy Storchaka 2016-11-16 10:19:20 +02:00
commit 3b73ea1278
22 changed files with 125 additions and 80 deletions

View file

@ -2412,7 +2412,7 @@ type_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds)
}
add_dict++;
}
if (PyUnicode_CompareWithASCIIString(tmp, "__weakref__") == 0) {
if (_PyUnicode_EqualToASCIIString(tmp, "__weakref__")) {
if (!may_add_weak || add_weak) {
PyErr_SetString(PyExc_TypeError,
"__weakref__ slot disallowed: "
@ -2436,7 +2436,7 @@ type_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds)
if ((add_dict &&
_PyUnicode_CompareWithId(tmp, &PyId___dict__) == 0) ||
(add_weak &&
PyUnicode_CompareWithASCIIString(tmp, "__weakref__") == 0))
_PyUnicode_EqualToASCIIString(tmp, "__weakref__")))
continue;
tmp =_Py_Mangle(name, tmp);
if (!tmp) {