Skip to content

Commit 5e79d52

Browse files
fix merge
1 parent aadb482 commit 5e79d52

File tree

1 file changed

+42
-29
lines changed

1 file changed

+42
-29
lines changed

Objects/dictobject.c

Lines changed: 42 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1581,40 +1581,33 @@ _Py_dict_lookup_threadsafe(PyDictObject *mp, PyObject *key, Py_hash_t hash, PyOb
15811581
return ix;
15821582
}
15831583

1584-
static Py_ssize_t
1585-
unicodekeys_lookup_unicode_threadsafe_stackref(PyDictKeysObject* dk, PyObject *key, Py_hash_t hash, _PyStackRef *value_addr)
1586-
{
1587-
assert(PyUnicode_CheckExact(key));
1588-
assert(dk->dk_kind == DICT_KEYS_UNICODE);
1589-
Py_ssize_t ix = unicodekeys_lookup_unicode_threadsafe(dk, key, hash);
1590-
if (ix == DKIX_EMPTY) {
1591-
*value_addr = PyStackRef_NULL;
1592-
return DKIX_EMPTY;
1593-
} else if (ix >= 0) {
1594-
PyObject **addr_of_value = &DK_UNICODE_ENTRIES(dk)[ix].me_value;
1595-
PyObject *value = _Py_atomic_load_ptr(addr_of_value);
1596-
if (value == NULL) {
1597-
*value_addr = PyStackRef_NULL;
1598-
return DKIX_EMPTY;
1599-
}
1600-
if (_PyObject_HasDeferredRefcount(value)) {
1601-
*value_addr = (_PyStackRef){ .bits = (uintptr_t)value | Py_TAG_DEFERRED };
1602-
return ix;
1603-
}
1604-
if (_Py_TryIncrefCompare(addr_of_value, value)) {
1605-
*value_addr = PyStackRef_FromPyObjectSteal(value);
1606-
return ix;
1607-
}
1608-
}
1609-
}
1610-
16111584

16121585
Py_ssize_t
16131586
_Py_dict_lookup_threadsafe_stackref(PyDictObject *mp, PyObject *key, Py_hash_t hash, _PyStackRef *value_addr)
16141587
{
16151588
PyDictKeysObject *dk = _Py_atomic_load_ptr(&mp->ma_keys);
16161589
if (dk->dk_kind == DICT_KEYS_UNICODE && PyUnicode_CheckExact(key)) {
1617-
return unicodekeys_lookup_unicode_threadsafe_stackref(dk, key, hash, value_addr);
1590+
Py_ssize_t ix = unicodekeys_lookup_unicode_threadsafe(dk, key, hash);
1591+
if (ix == DKIX_EMPTY) {
1592+
*value_addr = PyStackRef_NULL;
1593+
return ix;
1594+
}
1595+
else if (ix >= 0) {
1596+
PyObject **addr_of_value = &DK_UNICODE_ENTRIES(dk)[ix].me_value;
1597+
PyObject *value = _Py_atomic_load_ptr(addr_of_value);
1598+
if (value == NULL) {
1599+
*value_addr = PyStackRef_NULL;
1600+
return DKIX_EMPTY;
1601+
}
1602+
if (_PyObject_HasDeferredRefcount(value)) {
1603+
*value_addr = (_PyStackRef){ .bits = (uintptr_t)value | Py_TAG_DEFERRED };
1604+
return ix;
1605+
}
1606+
if (_Py_TryIncrefCompare(addr_of_value, value)) {
1607+
*value_addr = PyStackRef_FromPyObjectSteal(value);
1608+
return ix;
1609+
}
1610+
}
16181611
}
16191612

16201613
PyObject *obj;
@@ -1639,7 +1632,27 @@ _Py_dict_lookup_unicode_threadsafe_stackref(PyDictObject *mp, PyObject *key, Py_
16391632
assert(PyUnicode_CheckExact(key));
16401633
PyDictKeysObject *dk = _Py_atomic_load_ptr(&mp->ma_keys);
16411634
if (dk->dk_kind == DICT_KEYS_UNICODE) {
1642-
return unicodekeys_lookup_unicode_threadsafe_stackref(dk, key, hash, value_addr);
1635+
Py_ssize_t ix = unicodekeys_lookup_unicode_threadsafe(dk, key, hash);
1636+
if (ix == DKIX_EMPTY) {
1637+
*value_addr = PyStackRef_NULL;
1638+
return ix;
1639+
}
1640+
else if (ix >= 0) {
1641+
PyObject **addr_of_value = &DK_UNICODE_ENTRIES(dk)[ix].me_value;
1642+
PyObject *value = _Py_atomic_load_ptr(addr_of_value);
1643+
if (value == NULL) {
1644+
*value_addr = PyStackRef_NULL;
1645+
return DKIX_EMPTY;
1646+
}
1647+
if (_PyObject_HasDeferredRefcount(value)) {
1648+
*value_addr = (_PyStackRef){ .bits = (uintptr_t)value | Py_TAG_DEFERRED };
1649+
return ix;
1650+
}
1651+
if (_Py_TryIncrefCompare(addr_of_value, value)) {
1652+
*value_addr = PyStackRef_FromPyObjectSteal(value);
1653+
return ix;
1654+
}
1655+
}
16431656
}
16441657

16451658
PyObject *obj;

0 commit comments

Comments
 (0)