mirror of
https://github.com/python/cpython.git
synced 2025-10-18 04:38:07 +00:00
bpo-40609: Remove _Py_hashtable_t.key_size (GH-20060)
Rewrite _Py_hashtable_t type to always store the key as a "const void *" pointer. Add an explicit "key" member to _Py_hashtable_entry_t. Remove _Py_hashtable_t.key_size member. hash and compare functions drop their hash table parameter, and their 'key' parameter type becomes "const void *".
This commit is contained in:
parent
9e2ca17420
commit
f9b3b582b8
4 changed files with 120 additions and 188 deletions
|
@ -549,7 +549,7 @@ static int
|
|||
w_init_refs(WFILE *wf, int version)
|
||||
{
|
||||
if (version >= 3) {
|
||||
wf->hashtable = _Py_hashtable_new(sizeof(PyObject *), sizeof(int),
|
||||
wf->hashtable = _Py_hashtable_new(sizeof(int),
|
||||
_Py_hashtable_hash_ptr,
|
||||
_Py_hashtable_compare_direct);
|
||||
if (wf->hashtable == NULL) {
|
||||
|
@ -564,9 +564,7 @@ static int
|
|||
w_decref_entry(_Py_hashtable_t *ht, _Py_hashtable_entry_t *entry,
|
||||
void *Py_UNUSED(data))
|
||||
{
|
||||
PyObject *entry_key;
|
||||
|
||||
_Py_HASHTABLE_ENTRY_READ_KEY(ht, entry, entry_key);
|
||||
PyObject *entry_key = (PyObject *)entry->key;
|
||||
Py_XDECREF(entry_key);
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue