diff options
author | Damien George <damien.p.george@gmail.com> | 2015-10-18 23:09:04 +0100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2015-10-20 12:38:54 +0100 |
commit | 04353cc85e02e96bba374c2f2097d2e192c95193 (patch) | |
tree | 5d541cd8635f9405060fb49caf7cd1e08a998b97 /py/objstr.c | |
parent | 183edefddd8c08dd989fa7bec2d33d8b4130e1dc (diff) |
py: With obj repr "C", change raw str accessor from macro to function.
This saves around 1000 bytes (Thumb2 arch) because in repr "C" it is
costly to check and extract a qstr. So making such check/extract a
function instead of a macro saves lots of code space.
Diffstat (limited to 'py/objstr.c')
-rw-r--r-- | py/objstr.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/py/objstr.c b/py/objstr.c index 6ada37b90..94a63c231 100644 --- a/py/objstr.c +++ b/py/objstr.c @@ -2038,6 +2038,17 @@ const char *mp_obj_str_get_data(mp_obj_t self_in, mp_uint_t *len) { } } +#if MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_C +const byte *mp_obj_str_get_data_no_check(mp_obj_t self_in, mp_uint_t *len) { + if (MP_OBJ_IS_QSTR(self_in)) { + return qstr_data(MP_OBJ_QSTR_VALUE(self_in), len); + } else { + *len = ((mp_obj_str_t*)self_in)->len; + return ((mp_obj_str_t*)self_in)->data; + } +} +#endif + /******************************************************************************/ /* str iterator */ |