gh-121266: Change dict check_lookup() return type to int (#121581)

This commit is contained in:
Victor Stinner 2024-07-17 21:52:19 +02:00 committed by GitHub
parent b826e459ca
commit 51da3dfbf3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 11 additions and 11 deletions

View File

@ -1050,7 +1050,7 @@ lookdict_index(PyDictKeysObject *k, Py_hash_t hash, Py_ssize_t index)
static inline Py_ALWAYS_INLINE Py_ssize_t static inline Py_ALWAYS_INLINE Py_ssize_t
do_lookup(PyDictObject *mp, PyDictKeysObject *dk, PyObject *key, Py_hash_t hash, do_lookup(PyDictObject *mp, PyDictKeysObject *dk, PyObject *key, Py_hash_t hash,
Py_ssize_t (*check_lookup)(PyDictObject *, PyDictKeysObject *, void *, Py_ssize_t ix, PyObject *key, Py_hash_t)) int (*check_lookup)(PyDictObject *, PyDictKeysObject *, void *, Py_ssize_t ix, PyObject *key, Py_hash_t))
{ {
void *ep0 = _DK_ENTRIES(dk); void *ep0 = _DK_ENTRIES(dk);
size_t mask = DK_MASK(dk); size_t mask = DK_MASK(dk);
@ -1060,7 +1060,7 @@ do_lookup(PyDictObject *mp, PyDictKeysObject *dk, PyObject *key, Py_hash_t hash,
for (;;) { for (;;) {
ix = dictkeys_get_index(dk, i); ix = dictkeys_get_index(dk, i);
if (ix >= 0) { if (ix >= 0) {
Py_ssize_t cmp = check_lookup(mp, dk, ep0, ix, key, hash); int cmp = check_lookup(mp, dk, ep0, ix, key, hash);
if (cmp < 0) { if (cmp < 0) {
return cmp; return cmp;
} else if (cmp) { } else if (cmp) {
@ -1076,7 +1076,7 @@ do_lookup(PyDictObject *mp, PyDictKeysObject *dk, PyObject *key, Py_hash_t hash,
// Manual loop unrolling // Manual loop unrolling
ix = dictkeys_get_index(dk, i); ix = dictkeys_get_index(dk, i);
if (ix >= 0) { if (ix >= 0) {
Py_ssize_t cmp = check_lookup(mp, dk, ep0, ix, key, hash); int cmp = check_lookup(mp, dk, ep0, ix, key, hash);
if (cmp < 0) { if (cmp < 0) {
return cmp; return cmp;
} else if (cmp) { } else if (cmp) {
@ -1092,7 +1092,7 @@ do_lookup(PyDictObject *mp, PyDictKeysObject *dk, PyObject *key, Py_hash_t hash,
Py_UNREACHABLE(); Py_UNREACHABLE();
} }
static inline Py_ALWAYS_INLINE Py_ssize_t static inline Py_ALWAYS_INLINE int
compare_unicode_generic(PyDictObject *mp, PyDictKeysObject *dk, compare_unicode_generic(PyDictObject *mp, PyDictKeysObject *dk,
void *ep0, Py_ssize_t ix, PyObject *key, Py_hash_t hash) void *ep0, Py_ssize_t ix, PyObject *key, Py_hash_t hash)
{ {
@ -1127,7 +1127,7 @@ unicodekeys_lookup_generic(PyDictObject *mp, PyDictKeysObject* dk, PyObject *key
return do_lookup(mp, dk, key, hash, compare_unicode_generic); return do_lookup(mp, dk, key, hash, compare_unicode_generic);
} }
static inline Py_ALWAYS_INLINE Py_ssize_t static inline Py_ALWAYS_INLINE int
compare_unicode_unicode(PyDictObject *mp, PyDictKeysObject *dk, compare_unicode_unicode(PyDictObject *mp, PyDictKeysObject *dk,
void *ep0, Py_ssize_t ix, PyObject *key, Py_hash_t hash) void *ep0, Py_ssize_t ix, PyObject *key, Py_hash_t hash)
{ {
@ -1148,7 +1148,7 @@ unicodekeys_lookup_unicode(PyDictKeysObject* dk, PyObject *key, Py_hash_t hash)
return do_lookup(NULL, dk, key, hash, compare_unicode_unicode); return do_lookup(NULL, dk, key, hash, compare_unicode_unicode);
} }
static inline Py_ALWAYS_INLINE Py_ssize_t static inline Py_ALWAYS_INLINE int
compare_generic(PyDictObject *mp, PyDictKeysObject *dk, compare_generic(PyDictObject *mp, PyDictKeysObject *dk,
void *ep0, Py_ssize_t ix, PyObject *key, Py_hash_t hash) void *ep0, Py_ssize_t ix, PyObject *key, Py_hash_t hash)
{ {
@ -1343,8 +1343,8 @@ ensure_shared_on_resize(PyDictObject *mp)
#ifdef Py_GIL_DISABLED #ifdef Py_GIL_DISABLED
static inline Py_ALWAYS_INLINE static inline Py_ALWAYS_INLINE int
Py_ssize_t compare_unicode_generic_threadsafe(PyDictObject *mp, PyDictKeysObject *dk, compare_unicode_generic_threadsafe(PyDictObject *mp, PyDictKeysObject *dk,
void *ep0, Py_ssize_t ix, PyObject *key, Py_hash_t hash) void *ep0, Py_ssize_t ix, PyObject *key, Py_hash_t hash)
{ {
PyDictUnicodeEntry *ep = &((PyDictUnicodeEntry *)ep0)[ix]; PyDictUnicodeEntry *ep = &((PyDictUnicodeEntry *)ep0)[ix];
@ -1386,7 +1386,7 @@ unicodekeys_lookup_generic_threadsafe(PyDictObject *mp, PyDictKeysObject* dk, Py
return do_lookup(mp, dk, key, hash, compare_unicode_generic_threadsafe); return do_lookup(mp, dk, key, hash, compare_unicode_generic_threadsafe);
} }
static inline Py_ALWAYS_INLINE Py_ssize_t static inline Py_ALWAYS_INLINE int
compare_unicode_unicode_threadsafe(PyDictObject *mp, PyDictKeysObject *dk, compare_unicode_unicode_threadsafe(PyDictObject *mp, PyDictKeysObject *dk,
void *ep0, Py_ssize_t ix, PyObject *key, Py_hash_t hash) void *ep0, Py_ssize_t ix, PyObject *key, Py_hash_t hash)
{ {
@ -1420,8 +1420,8 @@ unicodekeys_lookup_unicode_threadsafe(PyDictKeysObject* dk, PyObject *key, Py_ha
return do_lookup(NULL, dk, key, hash, compare_unicode_unicode_threadsafe); return do_lookup(NULL, dk, key, hash, compare_unicode_unicode_threadsafe);
} }
static inline Py_ALWAYS_INLINE static inline Py_ALWAYS_INLINE int
Py_ssize_t compare_generic_threadsafe(PyDictObject *mp, PyDictKeysObject *dk, compare_generic_threadsafe(PyDictObject *mp, PyDictKeysObject *dk,
void *ep0, Py_ssize_t ix, PyObject *key, Py_hash_t hash) void *ep0, Py_ssize_t ix, PyObject *key, Py_hash_t hash)
{ {
PyDictKeyEntry *ep = &((PyDictKeyEntry *)ep0)[ix]; PyDictKeyEntry *ep = &((PyDictKeyEntry *)ep0)[ix];