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:57 +02:00
commit 1a73bf365e
22 changed files with 125 additions and 80 deletions

View file

@ -5166,9 +5166,9 @@ long_to_bytes(PyLongObject *v, PyObject *args, PyObject *kwds)
return NULL;
}
if (!PyUnicode_CompareWithASCIIString(byteorder_str, "little"))
if (_PyUnicode_EqualToASCIIString(byteorder_str, "little"))
little_endian = 1;
else if (!PyUnicode_CompareWithASCIIString(byteorder_str, "big"))
else if (_PyUnicode_EqualToASCIIString(byteorder_str, "big"))
little_endian = 0;
else {
PyErr_SetString(PyExc_ValueError,
@ -5249,9 +5249,9 @@ long_from_bytes(PyTypeObject *type, PyObject *args, PyObject *kwds)
return NULL;
}
if (!PyUnicode_CompareWithASCIIString(byteorder_str, "little"))
if (_PyUnicode_EqualToASCIIString(byteorder_str, "little"))
little_endian = 1;
else if (!PyUnicode_CompareWithASCIIString(byteorder_str, "big"))
else if (_PyUnicode_EqualToASCIIString(byteorder_str, "big"))
little_endian = 0;
else {
PyErr_SetString(PyExc_ValueError,