From d56bc6e03d842b1a2c91c987ba936752d0c2fe1b Mon Sep 17 00:00:00 2001 From: Damien George Date: Fri, 27 Dec 2019 23:33:34 +1100 Subject: [PATCH] py/obj.h: Use 32-bit shift in MP_OBJ_NEW_QSTR calc for obj-repr D. The qst value is always small enough to fit in 31-bits (even less) and using a 32-bit shift rather than a 64-bit shift reduces code size by about 300 bytes. --- py/obj.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py/obj.h b/py/obj.h index b4ee911084..efeb14b433 100644 --- a/py/obj.h +++ b/py/obj.h @@ -178,7 +178,7 @@ static inline bool mp_obj_is_small_int(mp_const_obj_t o) static inline bool mp_obj_is_qstr(mp_const_obj_t o) { return ((((uint64_t)(o)) & 0xffff000000000000) == 0x0002000000000000); } #define MP_OBJ_QSTR_VALUE(o) ((((uint32_t)(o)) >> 1) & 0xffffffff) -#define MP_OBJ_NEW_QSTR(qst) ((mp_obj_t)((((mp_uint_t)(qst)) << 1) | 0x0002000000000001)) +#define MP_OBJ_NEW_QSTR(qst) ((mp_obj_t)(((uint64_t)(((uint32_t)(qst)) << 1)) | 0x0002000000000001)) #if MICROPY_PY_BUILTINS_FLOAT