diff options
author | Matthias Görgens <matthias.goergens@gmail.com> | 2022-08-18 09:19:21 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-18 09:19:21 (GMT) |
commit | 4a6fa894650cfd08da172b798a745961d4d0f398 (patch) | |
tree | 747e34df3c4188ed2bb72d33e4b4a9587c3382b5 /Objects | |
parent | 586fc02be5b3e103bfddd49654034a898a8d6dfc (diff) | |
download | cpython-4a6fa894650cfd08da172b798a745961d4d0f398.zip cpython-4a6fa894650cfd08da172b798a745961d4d0f398.tar.gz cpython-4a6fa894650cfd08da172b798a745961d4d0f398.tar.bz2 |
Remove dead code in _PyDict_GetItemHint and rename to _PyDict_LookupIndex (GH-95948)
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/dictobject.c | 44 |
1 files changed, 3 insertions, 41 deletions
diff --git a/Objects/dictobject.c b/Objects/dictobject.c index d820348..0cb95d5 100644 --- a/Objects/dictobject.c +++ b/Objects/dictobject.c @@ -1686,50 +1686,12 @@ PyDict_GetItem(PyObject *op, PyObject *key) } Py_ssize_t -_PyDict_GetItemHint(PyDictObject *mp, PyObject *key, - Py_ssize_t hint, PyObject **value) +_PyDict_LookupIndex(PyDictObject *mp, PyObject *key) { - assert(*value == NULL); + PyObject *value; assert(PyDict_CheckExact((PyObject*)mp)); assert(PyUnicode_CheckExact(key)); - if (hint >= 0 && hint < mp->ma_keys->dk_nentries) { - PyObject *res = NULL; - - if (DK_IS_UNICODE(mp->ma_keys)) { - PyDictUnicodeEntry *ep = DK_UNICODE_ENTRIES(mp->ma_keys) + (size_t)hint; - if (ep->me_key == key) { - if (mp->ma_keys->dk_kind == DICT_KEYS_SPLIT) { - assert(mp->ma_values != NULL); - res = mp->ma_values->values[(size_t)hint]; - } - else { - res = ep->me_value; - } - if (res != NULL) { - *value = res; - return hint; - } - } - } - else { - PyDictKeyEntry *ep = DK_ENTRIES(mp->ma_keys) + (size_t)hint; - if (ep->me_key == key) { - if (mp->ma_keys->dk_kind == DICT_KEYS_SPLIT) { - assert(mp->ma_values != NULL); - res = mp->ma_values->values[(size_t)hint]; - } - else { - res = ep->me_value; - } - if (res != NULL) { - *value = res; - return hint; - } - } - } - } - Py_hash_t hash = unicode_get_hash(key); if (hash == -1) { hash = PyObject_Hash(key); @@ -1738,7 +1700,7 @@ _PyDict_GetItemHint(PyDictObject *mp, PyObject *key, } } - return _Py_dict_lookup(mp, key, hash, value); + return _Py_dict_lookup(mp, key, hash, &value); } /* Same as PyDict_GetItemWithError() but with hash supplied by caller. |