@@ -1342,10 +1342,8 @@ insert_split_dict(PyInterpreterState *interp, PyDictObject *mp,
1342
1342
LOCK_KEYS (keys );
1343
1343
if (keys -> dk_usable <= 0 ) {
1344
1344
/* Need to resize. */
1345
- dictkeys_incref (keys );
1346
- int ins = insertion_resize (interp , mp , 1 );
1347
- dictkeys_decref (interp , keys );
1348
1345
UNLOCK_KEYS (keys );
1346
+ int ins = insertion_resize (interp , mp , 1 );
1349
1347
if (ins < 0 ) {
1350
1348
return -1 ;
1351
1349
}
@@ -1371,30 +1369,6 @@ insert_split_dict(PyInterpreterState *interp, PyDictObject *mp,
1371
1369
return 0 ;
1372
1370
}
1373
1371
1374
- static int
1375
- convert_to_nonunicode_keys (PyInterpreterState * interp , PyDictObject * mp )
1376
- {
1377
- PyDictKeysObject * keys = mp -> ma_keys ;
1378
- if (_PyDict_HasSplitTable (mp )) {
1379
- LOCK_KEYS (keys );
1380
- dictkeys_incref (keys );
1381
- } else {
1382
- keys = NULL ;
1383
- }
1384
-
1385
- int res = insertion_resize (interp , mp , 0 );
1386
-
1387
- if (keys != NULL ) {
1388
- dictkeys_decref (interp , keys );
1389
- UNLOCK_KEYS (keys );
1390
- }
1391
- if (res < 0 ) {
1392
- return res;
1393
- }
1394
- assert (mp -> ma_keys -> dk_kind == DICT_KEYS_GENERAL );
1395
- return 0 ;
1396
- }
1397
-
1398
1372
/*
1399
1373
Internal routine to insert a new item into the table.
1400
1374
Used both by the internal resize routine and by the public insert routine.
@@ -1410,9 +1384,9 @@ insertdict(PyInterpreterState *interp, PyDictObject *mp,
1410
1384
ASSERT_DICT_LOCKED (mp );
1411
1385
1412
1386
if (DK_IS_UNICODE (mp -> ma_keys ) && !PyUnicode_CheckExact (key )) {
1413
- if (convert_to_nonunicode_keys (interp , mp ) < 0 ) {
1387
+ if (insertion_resize (interp , mp , 0 ) < 0 )
1414
1388
goto Fail ;
1415
- }
1389
+ assert ( mp -> ma_keys -> dk_kind == DICT_KEYS_GENERAL );
1416
1390
}
1417
1391
1418
1392
Py_ssize_t ix = _Py_dict_lookup (mp , key , hash , & old_value );
@@ -3803,7 +3777,7 @@ dict_setdefault_ref_lock_held(PyObject *d, PyObject *key, PyObject *default_valu
3803
3777
}
3804
3778
3805
3779
if (!PyUnicode_CheckExact (key ) && DK_IS_UNICODE (mp -> ma_keys )) {
3806
- if (convert_to_nonunicode_keys (interp , mp ) < 0 ) {
3780
+ if (insertion_resize (interp , mp , 0 ) < 0 ) {
3807
3781
if (result ) {
3808
3782
* result = NULL ;
3809
3783
}
@@ -3997,8 +3971,6 @@ dict_popitem_impl(PyDictObject *self)
3997
3971
}
3998
3972
/* Convert split table to combined table */
3999
3973
if (_PyDict_HasSplitTable (self )) {
4000
- PyDictKeysObject * keys = self -> ma_keys ;
4001
-
4002
3974
if (dictresize (interp , self , DK_LOG_SIZE (self -> ma_keys ), 1 ) < 0 ) {
4003
3975
Py_DECREF (res );
4004
3976
return NULL ;
0 commit comments