Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite0c87c6

Browse files
authored
gh-124502: Remove _PyUnicode_EQ() function (#125114)
* Replace unicode_compare_eq() with unicode_eq().* Use unicode_eq() in setobject.c.* Replace _PyUnicode_EQ() with _PyUnicode_Equal().* Remove unicode_compare_eq() and _PyUnicode_EQ().
1 parent7f93dbf commite0c87c6

File tree

4 files changed

+10
-39
lines changed

4 files changed

+10
-39
lines changed

‎Include/internal/pycore_unicodeobject.h‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -252,11 +252,7 @@ extern Py_ssize_t _PyUnicode_InsertThousandsGrouping(
252252

253253
externPyObject*_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-
externint_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‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040
#include"pycore_pyatomic_ft_wrappers.h"// FT_ATOMIC_LOAD_SSIZE_RELAXED()
4141
#include"pycore_pyerrors.h"// _PyErr_SetKeyError()
4242
#include"pycore_setobject.h"// _PySet_NextEntry() definition
43+
44+
#include"stringlib/eq.h"// unicode_eq()
4345
#include<stddef.h>// offsetof()
4446
#include"clinic/setobject.c.h"
4547

@@ -96,7 +98,7 @@ set_lookkey(PySetObject *so, PyObject *key, Py_hash_t hash)
9698
returnentry;
9799
if (PyUnicode_CheckExact(startkey)
98100
&&PyUnicode_CheckExact(key)
99-
&&_PyUnicode_EQ(startkey,key))
101+
&&unicode_eq(startkey,key))
100102
returnentry;
101103
table=so->table;
102104
Py_INCREF(startkey);
@@ -157,7 +159,7 @@ set_add_entry(PySetObject *so, PyObject *key, Py_hash_t hash)
157159
gotofound_active;
158160
if (PyUnicode_CheckExact(startkey)
159161
&&PyUnicode_CheckExact(key)
160-
&&_PyUnicode_EQ(startkey,key))
162+
&&unicode_eq(startkey,key))
161163
gotofound_active;
162164
table=so->table;
163165
Py_INCREF(startkey);

‎Objects/unicodeobject.c‎

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,6 @@ _PyUnicode_InternedSize_Immortal(void)
261261
}
262262

263263
staticPy_hash_tunicode_hash(PyObject*);
264-
staticintunicode_compare_eq(PyObject*,PyObject*);
265264

266265
staticPy_uhash_t
267266
hashtable_unicode_hash(constvoid*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-
returnunicode_compare_eq(obj1,obj2);
277+
returnunicode_eq(obj1,obj2);
279278
}
280279
else {
281280
returnobj1==obj2;
@@ -10968,26 +10967,6 @@ unicode_compare(PyObject *str1, PyObject *str2)
1096810967
#undef COMPARE
1096910968
}
1097010969

10971-
staticint
10972-
unicode_compare_eq(PyObject*str1,PyObject*str2)
10973-
{
10974-
intkind;
10975-
constvoid*data1,*data2;
10976-
Py_ssize_tlen;
10977-
intcmp;
10978-
10979-
len=PyUnicode_GET_LENGTH(str1);
10980-
if (PyUnicode_GET_LENGTH(str2)!=len)
10981-
return0;
10982-
kind=PyUnicode_KIND(str1);
10983-
if (PyUnicode_KIND(str2)!=kind)
10984-
return0;
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
return1;
1099910978
}
11000-
returnunicode_compare_eq(str1,str2);
10979+
returnunicode_eq(str1,str2);
1100110980
}
1100210981

1100310982

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

11216-
returnunicode_compare_eq(left,right_uni);
11195+
returnunicode_eq(left,right_uni);
1121711196
}
1121811197

1121911198
PyObject*
@@ -11241,7 +11220,7 @@ PyUnicode_RichCompare(PyObject *left, PyObject *right, int op)
1124111220
}
1124211221
}
1124311222
elseif (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
returnPyBool_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-
returnunicode_eq(aa,bb);
11258-
}
11259-
1126011233
int
1126111234
PyUnicode_Contains(PyObject*str,PyObject*substr)
1126211235
{

‎Python/getargs.c‎

Lines changed: 1 addition & 1 deletion
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
returnPy_NewRef(kwstack[i]);
20692069
}
20702070
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp