Skip to content

Commit a2536c0

Browse files
committed
pythongh-124502: Remove _PyUnicode_EQ() function
* Replace _PyUnicode_EQ() with _PyUnicode_Equal(). * Replace unicode_compare_eq() with unicode_eq(). * Remove unicode_compare_eq() and _PyUnicode_EQ().
1 parent c203955 commit a2536c0

File tree

4 files changed

+8
-39
lines changed

4 files changed

+8
-39
lines changed

Include/internal/pycore_unicodeobject.h

+1-5
Original file line numberDiff line numberDiff line change
@@ -252,11 +252,7 @@ extern Py_ssize_t _PyUnicode_InsertThousandsGrouping(
252252

253253
extern PyObject* _PyUnicode_FormatLong(PyObject *, int, int, int);
254254

255-
/* Fast equality check when the inputs are known to be exact unicode types
256-
and where the hash values are equal (i.e. a very probable match) */
257-
extern int _PyUnicode_EQ(PyObject *, PyObject *);
258-
259-
// Equality check.
255+
// Fast equality check when the inputs are known to be exact unicode types.
260256
// Export for '_pickle' shared extension.
261257
PyAPI_FUNC(int) _PyUnicode_Equal(PyObject *, PyObject *);
262258

Objects/setobject.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ set_lookkey(PySetObject *so, PyObject *key, Py_hash_t hash)
9696
return entry;
9797
if (PyUnicode_CheckExact(startkey)
9898
&& PyUnicode_CheckExact(key)
99-
&& _PyUnicode_EQ(startkey, key))
99+
&& _PyUnicode_Equal(startkey, key))
100100
return entry;
101101
table = so->table;
102102
Py_INCREF(startkey);
@@ -157,7 +157,7 @@ set_add_entry(PySetObject *so, PyObject *key, Py_hash_t hash)
157157
goto found_active;
158158
if (PyUnicode_CheckExact(startkey)
159159
&& PyUnicode_CheckExact(key)
160-
&& _PyUnicode_EQ(startkey, key))
160+
&& _PyUnicode_Equal(startkey, key))
161161
goto found_active;
162162
table = so->table;
163163
Py_INCREF(startkey);

Objects/unicodeobject.c

+4-31
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,6 @@ _PyUnicode_InternedSize_Immortal(void)
261261
}
262262

263263
static Py_hash_t unicode_hash(PyObject *);
264-
static int unicode_compare_eq(PyObject *, PyObject *);
265264

266265
static Py_uhash_t
267266
hashtable_unicode_hash(const void *key)
@@ -275,7 +274,7 @@ hashtable_unicode_compare(const void *key1, const void *key2)
275274
PyObject *obj1 = (PyObject *)key1;
276275
PyObject *obj2 = (PyObject *)key2;
277276
if (obj1 != NULL && obj2 != NULL) {
278-
return unicode_compare_eq(obj1, obj2);
277+
return unicode_eq(obj1, obj2);
279278
}
280279
else {
281280
return obj1 == obj2;
@@ -10968,26 +10967,6 @@ unicode_compare(PyObject *str1, PyObject *str2)
1096810967
#undef COMPARE
1096910968
}
1097010969

10971-
static int
10972-
unicode_compare_eq(PyObject *str1, PyObject *str2)
10973-
{
10974-
int kind;
10975-
const void *data1, *data2;
10976-
Py_ssize_t len;
10977-
int cmp;
10978-
10979-
len = PyUnicode_GET_LENGTH(str1);
10980-
if (PyUnicode_GET_LENGTH(str2) != len)
10981-
return 0;
10982-
kind = PyUnicode_KIND(str1);
10983-
if (PyUnicode_KIND(str2) != kind)
10984-
return 0;
10985-
data1 = PyUnicode_DATA(str1);
10986-
data2 = PyUnicode_DATA(str2);
10987-
10988-
cmp = memcmp(data1, data2, len * kind);
10989-
return (cmp == 0);
10990-
}
1099110970

1099210971
int
1099310972
_PyUnicode_Equal(PyObject *str1, PyObject *str2)
@@ -10997,7 +10976,7 @@ _PyUnicode_Equal(PyObject *str1, PyObject *str2)
1099710976
if (str1 == str2) {
1099810977
return 1;
1099910978
}
11000-
return unicode_compare_eq(str1, str2);
10979+
return unicode_eq(str1, str2);
1100110980
}
1100210981

1100310982

@@ -11213,7 +11192,7 @@ _PyUnicode_EqualToASCIIId(PyObject *left, _Py_Identifier *right)
1121311192
return 0;
1121411193
}
1121511194

11216-
return unicode_compare_eq(left, right_uni);
11195+
return unicode_eq(left, right_uni);
1121711196
}
1121811197

1121911198
PyObject *
@@ -11241,7 +11220,7 @@ PyUnicode_RichCompare(PyObject *left, PyObject *right, int op)
1124111220
}
1124211221
}
1124311222
else if (op == Py_EQ || op == Py_NE) {
11244-
result = unicode_compare_eq(left, right);
11223+
result = unicode_eq(left, right);
1124511224
result ^= (op == Py_NE);
1124611225
return PyBool_FromLong(result);
1124711226
}
@@ -11251,12 +11230,6 @@ PyUnicode_RichCompare(PyObject *left, PyObject *right, int op)
1125111230
}
1125211231
}
1125311232

11254-
int
11255-
_PyUnicode_EQ(PyObject *aa, PyObject *bb)
11256-
{
11257-
return unicode_eq(aa, bb);
11258-
}
11259-
1126011233
int
1126111234
PyUnicode_Contains(PyObject *str, PyObject *substr)
1126211235
{

Python/getargs.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -2064,7 +2064,7 @@ find_keyword(PyObject *kwnames, PyObject *const *kwstack, PyObject *key)
20642064
for (i = 0; i < nkwargs; i++) {
20652065
PyObject *kwname = PyTuple_GET_ITEM(kwnames, i);
20662066
assert(PyUnicode_Check(kwname));
2067-
if (_PyUnicode_EQ(kwname, key)) {
2067+
if (_PyUnicode_Equal(kwname, key)) {
20682068
return Py_NewRef(kwstack[i]);
20692069
}
20702070
}

0 commit comments

Comments
 (0)