Skip to content
Snippets Groups Projects
Commit 0b7a66ab authored by Damien George's avatar Damien George
Browse files

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.
parent ea5b59bf
No related branches found
No related tags found
No related merge requests found
...@@ -88,10 +88,8 @@ STATIC mp_obj_t bool_unary_op(mp_uint_t op, mp_obj_t o_in) { ...@@ -88,10 +88,8 @@ STATIC mp_obj_t bool_unary_op(mp_uint_t op, mp_obj_t o_in) {
} }
STATIC mp_obj_t bool_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) { STATIC mp_obj_t bool_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
if (MP_BINARY_OP_OR <= op && op <= MP_BINARY_OP_NOT_EQUAL) { mp_obj_bool_t *self = lhs_in;
return mp_binary_op(op, MP_OBJ_NEW_SMALL_INT(mp_obj_is_true(lhs_in)), rhs_in); return mp_binary_op(op, MP_OBJ_NEW_SMALL_INT(self->value), rhs_in);
}
return MP_OBJ_NULL; // op not supported
} }
const mp_obj_type_t mp_type_bool = { const mp_obj_type_t mp_type_bool = {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment