Skip to content

Commit 20daa07

Browse files
committed
Use _PyDict_GetItemHint instead of _Py_dict_lookup
1 parent 2b7aad1 commit 20daa07

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

Python/specialize.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -386,18 +386,14 @@ _Py_Specialize_LoadGlobal(
386386
_PyAdaptiveEntry *cache0 = &cache->adaptive;
387387
_PyLoadGlobalCache *cache1 = &cache[-1].load_global;
388388
assert(PyUnicode_CheckExact(name));
389-
Py_hash_t hash = PyObject_Hash(name);
390-
if (hash == -1) {
391-
return -1;
392-
}
393389
if (!PyDict_CheckExact(globals)) {
394390
goto fail;
395391
}
396-
if (((PyDictObject *)globals)->ma_keys->dk_kind == DICT_KEYS_SPLIT) {
392+
if (((PyDictObject *)globals)->ma_keys->dk_kind != DICT_KEYS_UNICODE) {
397393
goto fail;
398394
}
399-
PyObject *value;
400-
Py_ssize_t index = _Py_dict_lookup((PyDictObject *)globals, name, hash, &value);
395+
PyObject *value = NULL;
396+
Py_ssize_t index = _PyDict_GetItemHint((PyDictObject *)globals, name, -1, &value);
401397
assert (index != DKIX_ERROR);
402398
if (index != DKIX_EMPTY) {
403399
if (index != (uint16_t)index) {
@@ -415,10 +411,10 @@ _Py_Specialize_LoadGlobal(
415411
if (!PyDict_CheckExact(builtins)) {
416412
goto fail;
417413
}
418-
if (((PyDictObject *)builtins)->ma_keys->dk_kind == DICT_KEYS_SPLIT) {
414+
if (((PyDictObject *)builtins)->ma_keys->dk_kind != DICT_KEYS_UNICODE) {
419415
goto fail;
420416
}
421-
index = _Py_dict_lookup((PyDictObject *)builtins, name, hash, &value);
417+
index = _PyDict_GetItemHint((PyDictObject *)builtins, name, -1, &value);
422418
assert (index != DKIX_ERROR);
423419
if (index != (uint16_t)index) {
424420
goto fail;

0 commit comments

Comments
 (0)