summaryrefslogtreecommitdiffstats
path: root/Python/optimizer_bytecodes.c
diff options
context:
space:
mode:
Diffstat (limited to 'Python/optimizer_bytecodes.c')
-rw-r--r--Python/optimizer_bytecodes.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/Python/optimizer_bytecodes.c b/Python/optimizer_bytecodes.c
index a948ccc..da36704 100644
--- a/Python/optimizer_bytecodes.c
+++ b/Python/optimizer_bytecodes.c
@@ -367,34 +367,39 @@ dummy_func(void) {
}
op(_TO_BOOL, (value -- res)) {
- if (!optimize_to_bool(this_instr, ctx, value, &res)) {
+ int already_bool = optimize_to_bool(this_instr, ctx, value, &res);
+ if (!already_bool) {
res = sym_new_truthiness(ctx, value, true);
}
}
op(_TO_BOOL_BOOL, (value -- res)) {
- if (!optimize_to_bool(this_instr, ctx, value, &res)) {
+ int already_bool = optimize_to_bool(this_instr, ctx, value, &res);
+ if (!already_bool) {
sym_set_type(value, &PyBool_Type);
res = sym_new_truthiness(ctx, value, true);
}
}
op(_TO_BOOL_INT, (value -- res)) {
- if (!optimize_to_bool(this_instr, ctx, value, &res)) {
+ int already_bool = optimize_to_bool(this_instr, ctx, value, &res);
+ if (!already_bool) {
sym_set_type(value, &PyLong_Type);
res = sym_new_truthiness(ctx, value, true);
}
}
op(_TO_BOOL_LIST, (value -- res)) {
- if (!optimize_to_bool(this_instr, ctx, value, &res)) {
+ int already_bool = optimize_to_bool(this_instr, ctx, value, &res);
+ if (!already_bool) {
sym_set_type(value, &PyList_Type);
res = sym_new_type(ctx, &PyBool_Type);
}
}
op(_TO_BOOL_NONE, (value -- res)) {
- if (!optimize_to_bool(this_instr, ctx, value, &res)) {
+ int already_bool = optimize_to_bool(this_instr, ctx, value, &res);
+ if (!already_bool) {
sym_set_const(value, Py_None);
res = sym_new_const(ctx, Py_False);
}
@@ -415,7 +420,8 @@ dummy_func(void) {
}
op(_TO_BOOL_STR, (value -- res)) {
- if (!optimize_to_bool(this_instr, ctx, value, &res)) {
+ int already_bool = optimize_to_bool(this_instr, ctx, value, &res);
+ if (!already_bool) {
res = sym_new_truthiness(ctx, value, true);
}
}