summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYonatan Goldschmidt <yon.goldschmidt@gmail.com>2019-06-04 20:14:41 +0300
committerDamien George <damien.p.george@gmail.com>2019-06-05 10:54:23 +1000
commit7cf26ca4bd84134b9fbddaf032370e91326edb64 (patch)
treeeb72099751cda53eea185246e19ea1fc955077a4
parentfaf3d3e9e93a71b3947bf563e4ffe13cbd053cb8 (diff)
py/obj: Optimise small-int comparison to 0 in mp_obj_is_true.
Instead of converting to a small-int at runtime this can be done at compile time, then we only have a simple comparison during runtime. This reduces code size on some ports (e.g -4 on qemu-arm, -52 on unix nanbox), and for others at least doesn't increase code size.
-rw-r--r--py/obj.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/py/obj.c b/py/obj.c
index 122f0ea62..1797ee56b 100644
--- a/py/obj.c
+++ b/py/obj.c
@@ -113,7 +113,7 @@ bool mp_obj_is_true(mp_obj_t arg) {
} else if (arg == mp_const_none) {
return 0;
} else if (mp_obj_is_small_int(arg)) {
- if (MP_OBJ_SMALL_INT_VALUE(arg) == 0) {
+ if (arg == MP_OBJ_NEW_SMALL_INT(0)) {
return 0;
} else {
return 1;