extern PyObject* _PyUnicode_FormatLong(PyObject *, int, int, int);
-/* Fast equality check when the inputs are known to be exact unicode types
- and where the hash values are equal (i.e. a very probable match) */
-extern int _PyUnicode_EQ(PyObject *, PyObject *);
-
-// Equality check.
+// Fast equality check when the inputs are known to be exact unicode types.
// Export for '_pickle' shared extension.
PyAPI_FUNC(int) _PyUnicode_Equal(PyObject *, PyObject *);
#include "pycore_pyatomic_ft_wrappers.h" // FT_ATOMIC_LOAD_SSIZE_RELAXED()
#include "pycore_pyerrors.h" // _PyErr_SetKeyError()
#include "pycore_setobject.h" // _PySet_NextEntry() definition
+
+#include "stringlib/eq.h" // unicode_eq()
#include <stddef.h> // offsetof()
#include "clinic/setobject.c.h"
return entry;
if (PyUnicode_CheckExact(startkey)
&& PyUnicode_CheckExact(key)
- && _PyUnicode_EQ(startkey, key))
+ && unicode_eq(startkey, key))
return entry;
table = so->table;
Py_INCREF(startkey);
goto found_active;
if (PyUnicode_CheckExact(startkey)
&& PyUnicode_CheckExact(key)
- && _PyUnicode_EQ(startkey, key))
+ && unicode_eq(startkey, key))
goto found_active;
table = so->table;
Py_INCREF(startkey);
}
static Py_hash_t unicode_hash(PyObject *);
-static int unicode_compare_eq(PyObject *, PyObject *);
static Py_uhash_t
hashtable_unicode_hash(const void *key)
PyObject *obj1 = (PyObject *)key1;
PyObject *obj2 = (PyObject *)key2;
if (obj1 != NULL && obj2 != NULL) {
- return unicode_compare_eq(obj1, obj2);
+ return unicode_eq(obj1, obj2);
}
else {
return obj1 == obj2;
#undef COMPARE
}
-static int
-unicode_compare_eq(PyObject *str1, PyObject *str2)
-{
- int kind;
- const void *data1, *data2;
- Py_ssize_t len;
- int cmp;
-
- len = PyUnicode_GET_LENGTH(str1);
- if (PyUnicode_GET_LENGTH(str2) != len)
- return 0;
- kind = PyUnicode_KIND(str1);
- if (PyUnicode_KIND(str2) != kind)
- return 0;
- data1 = PyUnicode_DATA(str1);
- data2 = PyUnicode_DATA(str2);
-
- cmp = memcmp(data1, data2, len * kind);
- return (cmp == 0);
-}
int
_PyUnicode_Equal(PyObject *str1, PyObject *str2)
if (str1 == str2) {
return 1;
}
- return unicode_compare_eq(str1, str2);
+ return unicode_eq(str1, str2);
}
return 0;
}
- return unicode_compare_eq(left, right_uni);
+ return unicode_eq(left, right_uni);
}
PyObject *
}
}
else if (op == Py_EQ || op == Py_NE) {
- result = unicode_compare_eq(left, right);
+ result = unicode_eq(left, right);
result ^= (op == Py_NE);
return PyBool_FromLong(result);
}
}
}
-int
-_PyUnicode_EQ(PyObject *aa, PyObject *bb)
-{
- return unicode_eq(aa, bb);
-}
-
int
PyUnicode_Contains(PyObject *str, PyObject *substr)
{
for (i = 0; i < nkwargs; i++) {
PyObject *kwname = PyTuple_GET_ITEM(kwnames, i);
assert(PyUnicode_Check(kwname));
- if (_PyUnicode_EQ(kwname, key)) {
+ if (_PyUnicode_Equal(kwname, key)) {
return Py_NewRef(kwstack[i]);
}
}