Skip to content

Commit fc2e7f3

Browse files
committed
gh-161524: Move dict merge setup closer to its use
1 parent 04e06e5 commit fc2e7f3

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

‎Objects/dictobject.c‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4362,15 +4362,9 @@ dict_dict_merge(PyDictObject *mp, PyDictObject *other, int override, PyObject **
43624362
/* a.update(a) or a.update({}); nothing to do */
43634363
return 0;
43644364
if (mp->ma_used == 0) {
4365-
/* Since the target dict is empty, _PyDict_Contains_KnownHash()
4366-
* always returns 0. Setting override to 1
4367-
* skips the unnecessary test.
4368-
*/
4369-
override = 1;
4370-
PyDictKeysObject *okeys = other->ma_keys;
4371-
43724365
// Copy a combined table directly, compacting deleted entries.
43734366
if (mp->ma_values == NULL && other->ma_values == NULL) {
4367+
PyDictKeysObject *okeys = other->ma_keys;
43744368
PyDictKeysObject *keys;
43754369
if (other->ma_used == okeys->dk_nentries &&
43764370
(DK_LOG_SIZE(okeys) == PyDict_LOG_MINSIZE ||
@@ -4391,6 +4385,12 @@ dict_dict_merge(PyDictObject *mp, PyDictObject *other, int override, PyObject **
43914385
ASSERT_CONSISTENT(mp);
43924386
return 0;
43934387
}
4388+
4389+
/* Since the target dict is empty, _PyDict_Contains_KnownHash()
4390+
* always returns 0. Setting override to 1
4391+
* skips the unnecessary test.
4392+
*/
4393+
override = 1;
43944394
}
43954395
/* Do one big resize at the start, rather than
43964396
* incrementally resizing as we insert new items. Expect

0 commit comments

Comments
 (0)