Commit f84b3416 authored by Damien George's avatar Damien George
Browse files

py/objnone: Remove unnecessary handling of MP_UNARY_OP_BOOL.

bool(None) has a fast path in mp_obj_is_true so doesn't need to be
handled in none_unary_op.  The only caveat is that subclassing may
bypass the mp_obj_is_true function, but actually you aren't allowed to
subclass classes that have singleton instances like NoneType (see for
reference on this point).
parent 3fea1f01
......@@ -46,7 +46,7 @@ STATIC void none_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_
STATIC mp_obj_t none_unary_op(mp_uint_t op, mp_obj_t o_in) {
switch (op) {
case MP_UNARY_OP_BOOL: return mp_const_false;
// MP_UNARY_OP_BOOL is handled by a fast-path in mp_obj_is_true
case MP_UNARY_OP_HASH: return MP_OBJ_NEW_SMALL_INT((mp_uint_t)o_in);
default: return MP_OBJ_NULL; // op not supported
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment