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:17:58 +02:00
parent 5ebff7b300
commit f4934ea77d
21 changed files with 120 additions and 75 deletions

View file

@ -2395,7 +2395,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: "
@ -2419,7 +2419,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) {