Skip to content

Commit 2b077e3

Browse files
committed
Rewrite the slot-setting code a bit
IMO, things are more easier to follow this way (combined with the comment added to pyslot_offsets).
1 parent 2df9180 commit 2b077e3

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

Objects/typeobject.c

+5-4
Original file line numberDiff line numberDiff line change
@@ -3046,12 +3046,13 @@ PyType_FromModuleAndSpec(PyObject *module, PyType_Spec *spec, PyObject *bases)
30463046
}
30473047
else {
30483048
/* Copy other slots directly */
3049-
slot_offset = pyslot_offsets[slot->slot].slot_offset;
3050-
void *parent_slot = *(void**)((char*)res_start + slot_offset);
3051-
if (parent_slot == NULL) {
3049+
PySlot_Offset slotoffsets = pyslot_offsets[slot->slot];
3050+
slot_offset = slotoffsets.slot_offset;
3051+
if (slotoffsets.subslot_offset == -1) {
30523052
*(void**)((char*)res_start + slot_offset) = slot->pfunc;
30533053
} else {
3054-
subslot_offset = pyslot_offsets[slot->slot].subslot_offset;
3054+
void *parent_slot = *(void**)((char*)res_start + slot_offset);
3055+
subslot_offset = slotoffsets.subslot_offset;
30553056
*(void**)((char*)parent_slot + subslot_offset) = slot->pfunc;
30563057
}
30573058
}

0 commit comments

Comments
 (0)