Skip to content

Commit e68dc65

Browse files
committed
Address code review
1 parent a213390 commit e68dc65

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

Python/specialize.c

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2716,25 +2716,26 @@ _Py_Specialize_ToBool(_PyStackRef value_o, _Py_CODEUNIT *instr)
27162716
assert(_PyOpcode_Caches[TO_BOOL] == INLINE_CACHE_ENTRIES_TO_BOOL);
27172717
_PyToBoolCache *cache = (_PyToBoolCache *)(instr + 1);
27182718
PyObject *value = PyStackRef_AsPyObjectBorrow(value_o);
2719+
uint8_t specialized_op;
27192720
if (PyBool_Check(value)) {
2720-
specialize(instr, TO_BOOL_BOOL);
2721-
return;
2721+
specialized_op = TO_BOOL_BOOL;
2722+
goto success;
27222723
}
27232724
if (PyLong_CheckExact(value)) {
2724-
specialize(instr, TO_BOOL_INT);
2725-
return;
2725+
specialized_op = TO_BOOL_INT;
2726+
goto success;
27262727
}
27272728
if (PyList_CheckExact(value)) {
2728-
specialize(instr, TO_BOOL_LIST);
2729-
return;
2729+
specialized_op = TO_BOOL_LIST;
2730+
goto success;
27302731
}
27312732
if (Py_IsNone(value)) {
2732-
specialize(instr, TO_BOOL_NONE);
2733-
return;
2733+
specialized_op = TO_BOOL_NONE;
2734+
goto success;
27342735
}
27352736
if (PyUnicode_CheckExact(value)) {
2736-
specialize(instr, TO_BOOL_STR);
2737-
return;
2737+
specialized_op = TO_BOOL_STR;
2738+
goto success;
27382739
}
27392740
if (PyType_HasFeature(Py_TYPE(value), Py_TPFLAGS_HEAPTYPE)) {
27402741
unsigned int version = 0;
@@ -2751,10 +2752,13 @@ _Py_Specialize_ToBool(_PyStackRef value_o, _Py_CODEUNIT *instr)
27512752
assert(err == 0);
27522753
assert(version);
27532754
write_u32(cache->version, version);
2754-
specialize(instr, TO_BOOL_ALWAYS_TRUE);
2755-
return;
2755+
specialized_op = TO_BOOL_ALWAYS_TRUE;
2756+
goto success;
27562757
}
27572758
unspecialize(instr, to_bool_fail_kind(value));
2759+
return;
2760+
success:
2761+
specialize(instr, specialized_op);
27582762
}
27592763

27602764
static int

0 commit comments

Comments
 (0)