summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2015-09-04 16:46:15 +0100
committerDamien George <damien.p.george@gmail.com>2015-09-04 16:46:15 +0100
commit0b7a66ab9795948dfdffa65a4e542f86bc00f597 (patch)
treebbe4983d141b0fb3831c7d0228fa7bea7d45da17
parentea5b59bfe6421bf1db38ac39b2474dc4393c646e (diff)
downloadmicropython-0b7a66ab9795948dfdffa65a4e542f86bc00f597.tar.gz
micropython-0b7a66ab9795948dfdffa65a4e542f86bc00f597.zip
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.
-rw-r--r--py/objbool.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/py/objbool.c b/py/objbool.c
index fe33e961b6..e0640b42a3 100644
--- a/py/objbool.c
+++ b/py/objbool.c
@@ -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) {
- if (MP_BINARY_OP_OR <= op && op <= MP_BINARY_OP_NOT_EQUAL) {
- return mp_binary_op(op, MP_OBJ_NEW_SMALL_INT(mp_obj_is_true(lhs_in)), rhs_in);
- }
- return MP_OBJ_NULL; // op not supported
+ mp_obj_bool_t *self = lhs_in;
+ return mp_binary_op(op, MP_OBJ_NEW_SMALL_INT(self->value), rhs_in);
}
const mp_obj_type_t mp_type_bool = {