diff options
author | Raymond Hettinger <python@rcn.com> | 2015-07-04 23:04:44 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2015-07-04 23:04:44 (GMT) |
commit | ac2ef65c320606e30132ca58bbd6b5d6861ce644 (patch) | |
tree | 60314adce386a879a44b69e752d29568d63d894d /Objects | |
parent | 7fe0507d07f819c76a79421ae54d547a54e6f35d (diff) | |
download | cpython-ac2ef65c320606e30132ca58bbd6b5d6861ce644.zip cpython-ac2ef65c320606e30132ca58bbd6b5d6861ce644.tar.gz cpython-ac2ef65c320606e30132ca58bbd6b5d6861ce644.tar.bz2 |
Make the unicode equality test an external function rather than in-lining it.
The real benefit of the unicode specialized function comes from
bypassing the overhead of PyObject_RichCompareBool() and not
from being in-lined (especially since there was almost no shared
data between the caller and callee). Also, the in-lining was
having a negative effect on code generation for the callee.
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/setobject.c | 9 | ||||
-rw-r--r-- | Objects/unicodeobject.c | 7 |
2 files changed, 11 insertions, 5 deletions
diff --git a/Objects/setobject.c b/Objects/setobject.c index cc87f28..d0fb4f1 100644 --- a/Objects/setobject.c +++ b/Objects/setobject.c @@ -29,7 +29,6 @@ #include "Python.h" #include "structmember.h" -#include "stringlib/eq.h" /* Object used as dummy key to fill deleted entries */ static PyObject _dummy_struct; @@ -74,7 +73,7 @@ set_lookkey(PySetObject *so, PyObject *key, Py_hash_t hash) return entry; if (PyUnicode_CheckExact(startkey) && PyUnicode_CheckExact(key) - && unicode_eq(startkey, key)) + && _PyUnicode_EQ(startkey, key)) return entry; Py_INCREF(startkey); cmp = PyObject_RichCompareBool(startkey, key, Py_EQ); @@ -100,7 +99,7 @@ set_lookkey(PySetObject *so, PyObject *key, Py_hash_t hash) return entry; if (PyUnicode_CheckExact(startkey) && PyUnicode_CheckExact(key) - && unicode_eq(startkey, key)) + && _PyUnicode_EQ(startkey, key)) return entry; Py_INCREF(startkey); cmp = PyObject_RichCompareBool(startkey, key, Py_EQ); @@ -155,7 +154,7 @@ set_insert_key(PySetObject *so, PyObject *key, Py_hash_t hash) goto found_active; if (PyUnicode_CheckExact(startkey) && PyUnicode_CheckExact(key) - && unicode_eq(startkey, key)) + && _PyUnicode_EQ(startkey, key)) goto found_active; Py_INCREF(startkey); cmp = PyObject_RichCompareBool(startkey, key, Py_EQ); @@ -183,7 +182,7 @@ set_insert_key(PySetObject *so, PyObject *key, Py_hash_t hash) goto found_active; if (PyUnicode_CheckExact(startkey) && PyUnicode_CheckExact(key) - && unicode_eq(startkey, key)) + && _PyUnicode_EQ(startkey, key)) goto found_active; Py_INCREF(startkey); cmp = PyObject_RichCompareBool(startkey, key, Py_EQ); diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 1eaf2e9..796e0b4 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -42,6 +42,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "Python.h" #include "ucnhash.h" #include "bytes_methods.h" +#include "stringlib/eq.h" #ifdef MS_WINDOWS #include <windows.h> @@ -10887,6 +10888,12 @@ PyUnicode_RichCompare(PyObject *left, PyObject *right, int op) } int +_PyUnicode_EQ(PyObject *aa, PyObject *bb) +{ + return unicode_eq(aa, bb); +} + +int PyUnicode_Contains(PyObject *container, PyObject *element) { PyObject *str, *sub; |