Skip to content

Commit 0b7a66a

Browse files
committed
py/objbool: Simplify dispatch of bool binary op.
This optimises (in speed and code size) for the common case where the binary op for the bool object is supported. Unsupported binary ops still behave the same.
1 parent ea5b59b commit 0b7a66a

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

py/objbool.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,8 @@ STATIC mp_obj_t bool_unary_op(mp_uint_t op, mp_obj_t o_in) {
8888
}
8989

9090
STATIC mp_obj_t bool_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
91-
if (MP_BINARY_OP_OR <= op && op <= MP_BINARY_OP_NOT_EQUAL) {
92-
return mp_binary_op(op, MP_OBJ_NEW_SMALL_INT(mp_obj_is_true(lhs_in)), rhs_in);
93-
}
94-
return MP_OBJ_NULL; // op not supported
91+
mp_obj_bool_t *self = lhs_in;
92+
return mp_binary_op(op, MP_OBJ_NEW_SMALL_INT(self->value), rhs_in);
9593
}
9694

9795
const mp_obj_type_t mp_type_bool = {

0 commit comments

Comments
 (0)