@@ -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
8000
+ 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 );
@@ -1432,7 +1406,8 @@ insertdict(PyInterpreterState *interp, PyDictObject *mp,
1432
1406
if (insert_combined_dict (interp , mp , hash , key , value ) < 0 ) {
1433
1407
goto Fail ;
1434
1408
}
1435
- } else {
1409
+ }
1410
+ else {
1436
1411
if (insert_split_dict (interp , mp , hash , key , value ) < 0 )
1437
1412
goto Fail ;
1438
1413
}
@@ -3803,7 +3778,7 @@ dict_setdefault_ref_lock_held(PyObject *d, PyObject *key, PyObject *default_valu
3803
3778
}
3804
3779
3805
3780
if (!PyUnicode_CheckExact (key ) && DK_IS_UNICODE (mp -> ma_keys )) {
3806
- if (convert_to_nonunicode_keys (interp , mp ) < 0 ) {
3781
+ if (insertion_resize (interp , mp , 0 ) < 0 ) {
3807
3782
if (result ) {
3808
3783
* result = NULL ;
3809
3784
}
@@ -3834,7 +3809,8 @@ dict_setdefault_ref_lock_held(PyObject *d, PyObject *key, PyObject *default_valu
3834
3809
}
3835
3810
return -1 ;
3836
3811
}
3837
- } else {
3812
+ }
3813
+ else {
3838
3814
if (insert_split_dict (interp , mp , hash , Py_NewRef (key ), Py_NewRef (value )) < 0 ) {
3839
3815
Py_DECREF (key );
3840
3816
Py_DECREF (value );
@@ -3997,8 +3973,6 @@ dict_popitem_impl(PyDictObject *self)
3997
3973
}
3998
3974
/* Convert split table to combined table */
3999
3975
if (_PyDict_HasSplitTable (self )) {
4000
- PyDictKeysObject * keys = self -> ma_keys ;
4001
-
4002
3976
if (dictresize (interp , self , DK_LOG_SIZE (self -> ma_keys ), 1 ) < 0 ) {
4003
3977
Py_DECREF (res );
4004
3978
return NULL ;
0 commit comments