mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
bpo-40575: Avoid unnecessary overhead in _PyDict_GetItemIdWithError() (GH-20018)
Avoid unnecessary overhead in _PyDict_GetItemIdWithError() by calling _PyDict_GetItem_KnownHash() instead of the more generic PyDict_GetItemWithError(), since we already know the hash of interned strings.
This commit is contained in:
parent
5b956ca42d
commit
6067d4bc3c
1 changed files with 3 additions and 1 deletions
|
@ -1492,7 +1492,9 @@ _PyDict_GetItemIdWithError(PyObject *dp, struct _Py_Identifier *key)
|
||||||
kv = _PyUnicode_FromId(key); /* borrowed */
|
kv = _PyUnicode_FromId(key); /* borrowed */
|
||||||
if (kv == NULL)
|
if (kv == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
return PyDict_GetItemWithError(dp, kv);
|
Py_hash_t hash = ((PyASCIIObject *) kv)->hash;
|
||||||
|
assert (hash != -1); /* interned strings have their hash value initialised */
|
||||||
|
return _PyDict_GetItem_KnownHash(dp, kv, hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue