summaryrefslogtreecommitdiff
path: root/py
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2019-12-27 23:15:52 +1100
committerDamien George <damien.p.george@gmail.com>2019-12-27 23:15:52 +1100
commit4c0176d13fbd99196c457cb38633040426efd758 (patch)
treeaee2468b8a1ede70085b573e5dc66793731641df /py
parente83ab7374bf1e8ee7b0644eb35567e30e6c21c36 (diff)
py/objstr: Don't use inline GET_STR_DATA_LEN for object-repr D.
Changing to use the helper function mp_obj_str_get_data_no_check() reduces code size of nan-boxing builds by about 1000 bytes.
Diffstat (limited to 'py')
-rw-r--r--py/objstr.c6
-rw-r--r--py/objstr.h2
2 files changed, 4 insertions, 4 deletions
diff --git a/py/objstr.c b/py/objstr.c
index e221982c5..822c9fc41 100644
--- a/py/objstr.c
+++ b/py/objstr.c
@@ -2153,13 +2153,13 @@ const char *mp_obj_str_get_data(mp_obj_t self_in, size_t *len) {
}
}
-#if MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_C
+#if MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_C || MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_D
const byte *mp_obj_str_get_data_no_check(mp_obj_t self_in, size_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;
+ *len = ((mp_obj_str_t*)MP_OBJ_TO_PTR(self_in))->len;
+ return ((mp_obj_str_t*)MP_OBJ_TO_PTR(self_in))->data;
}
}
#endif
diff --git a/py/objstr.h b/py/objstr.h
index 15ed7a225..ba300ccf5 100644
--- a/py/objstr.h
+++ b/py/objstr.h
@@ -50,7 +50,7 @@ typedef struct _mp_obj_str_t {
{ str_len = qstr_len(MP_OBJ_QSTR_VALUE(str_obj_in)); } else { str_len = ((mp_obj_str_t*)MP_OBJ_TO_PTR(str_obj_in))->len; }
// use this macro to extract the string data and length
-#if MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_C
+#if MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_C || MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_D
const byte *mp_obj_str_get_data_no_check(mp_obj_t self_in, size_t *len);
#define GET_STR_DATA_LEN(str_obj_in, str_data, str_len) \
size_t str_len; const byte *str_data = mp_obj_str_get_data_no_check(str_obj_in, &str_len);