gh-131510: Use PyUnstable_Unicode_GET_CACHED_HASH() (GH-141520)

Replace code that directly accesses PyASCIIObject.hash with
PyUnstable_Unicode_GET_CACHED_HASH().

Remove redundant "assert(PyUnicode_Check(op))" from
PyUnstable_Unicode_GET_CACHED_HASH(), _PyASCIIObject_CAST() already
implements the check.
This commit is contained in:
Victor Stinner 2025-11-14 11:13:24 +01:00 committed by GitHub
parent 181a2f4f2e
commit 3bacae5598
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 3 additions and 6 deletions

View file

@ -863,8 +863,7 @@ static inline Py_hash_t
_PyObject_HashFast(PyObject *op)
{
if (PyUnicode_CheckExact(op)) {
Py_hash_t hash = FT_ATOMIC_LOAD_SSIZE_RELAXED(
_PyASCIIObject_CAST(op)->hash);
Py_hash_t hash = PyUnstable_Unicode_GET_CACHED_HASH(op);
if (hash != -1) {
return hash;
}