diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2016-11-16 08:19:20 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2016-11-16 08:19:20 (GMT) |
commit | 3b73ea127892d0e1f9d8f12f88e4f9c0ba0b89b1 (patch) | |
tree | a1a58a83f9d60f7d5d02e5d116bb76ee13c42254 /Modules/_decimal | |
parent | 21060105d99a9153db44dd88eb750965392fd966 (diff) | |
parent | f4934ea77da38516731a75fbf9458b248d26dd81 (diff) | |
download | cpython-3b73ea127892d0e1f9d8f12f88e4f9c0ba0b89b1.zip cpython-3b73ea127892d0e1f9d8f12f88e4f9c0ba0b89b1.tar.gz cpython-3b73ea127892d0e1f9d8f12f88e4f9c0ba0b89b1.tar.bz2 |
Issue #28701: Replace PyUnicode_CompareWithASCIIString with _PyUnicode_EqualToASCIIString.
The latter function is more readable, faster and doesn't raise exceptions.
Diffstat (limited to 'Modules/_decimal')
-rw-r--r-- | Modules/_decimal/_decimal.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/Modules/_decimal/_decimal.c b/Modules/_decimal/_decimal.c index fcc1f15..9956786 100644 --- a/Modules/_decimal/_decimal.c +++ b/Modules/_decimal/_decimal.c @@ -1118,12 +1118,12 @@ context_getattr(PyObject *self, PyObject *name) PyObject *retval; if (PyUnicode_Check(name)) { - if (PyUnicode_CompareWithASCIIString(name, "traps") == 0) { + if (_PyUnicode_EqualToASCIIString(name, "traps")) { retval = ((PyDecContextObject *)self)->traps; Py_INCREF(retval); return retval; } - if (PyUnicode_CompareWithASCIIString(name, "flags") == 0) { + if (_PyUnicode_EqualToASCIIString(name, "flags")) { retval = ((PyDecContextObject *)self)->flags; Py_INCREF(retval); return retval; @@ -1143,10 +1143,10 @@ context_setattr(PyObject *self, PyObject *name, PyObject *value) } if (PyUnicode_Check(name)) { - if (PyUnicode_CompareWithASCIIString(name, "traps") == 0) { + if (_PyUnicode_EqualToASCIIString(name, "traps")) { return context_settraps_dict(self, value); } - if (PyUnicode_CompareWithASCIIString(name, "flags") == 0) { + if (_PyUnicode_EqualToASCIIString(name, "flags")) { return context_setstatus_dict(self, value); } } @@ -2449,14 +2449,14 @@ dectuple_as_str(PyObject *dectuple) tmp = PyTuple_GET_ITEM(dectuple, 2); if (PyUnicode_Check(tmp)) { /* special */ - if (PyUnicode_CompareWithASCIIString(tmp, "F") == 0) { + if (_PyUnicode_EqualToASCIIString(tmp, "F")) { strcat(sign_special, "Inf"); is_infinite = 1; } - else if (PyUnicode_CompareWithASCIIString(tmp, "n") == 0) { + else if (_PyUnicode_EqualToASCIIString(tmp, "n")) { strcat(sign_special, "NaN"); } - else if (PyUnicode_CompareWithASCIIString(tmp, "N") == 0) { + else if (_PyUnicode_EqualToASCIIString(tmp, "N")) { strcat(sign_special, "sNaN"); } else { |