mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
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:
parent
181a2f4f2e
commit
3bacae5598
4 changed files with 3 additions and 6 deletions
|
|
@ -6036,7 +6036,7 @@ static PyObject *
|
|||
update_cache(struct type_cache_entry *entry, PyObject *name, unsigned int version_tag, PyObject *value)
|
||||
{
|
||||
_Py_atomic_store_ptr_relaxed(&entry->value, value); /* borrowed */
|
||||
assert(_PyASCIIObject_CAST(name)->hash != -1);
|
||||
assert(PyUnstable_Unicode_GET_CACHED_HASH(name) != -1);
|
||||
OBJECT_STAT_INC_COND(type_cache_collisions, entry->name != Py_None && entry->name != name);
|
||||
// We're releasing this under the lock for simplicity sake because it's always a
|
||||
// exact unicode object or Py_None so it's safe to do so.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue