Skip to content

Commit 8de270b

Browse files
committed
py/objbool: Make a slight simplification of bool constructor.
Reduces code size for some archs.
1 parent eca1408 commit 8de270b

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

py/objbool.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,10 @@ STATIC mp_obj_t bool_make_new(const mp_obj_type_t *type_in, size_t n_args, size_
5656
(void)type_in;
5757
mp_arg_check_num(n_args, n_kw, 0, 1, false);
5858

59-
switch (n_args) {
60-
case 0:
61-
return mp_const_false;
62-
case 1:
63-
default: // must be 0 or 1
64-
if (mp_obj_is_true(args[0])) { return mp_const_true; } else { return mp_const_false; }
59+
if (n_args == 0) {
60+
return mp_const_false;
61+
} else {
62+
return mp_obj_new_bool(mp_obj_is_true(args[0]));
6563
}
6664
}
6765

0 commit comments

Comments
 (0)