summaryrefslogtreecommitdiff
path: root/py/objstr.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-08-27 09:20:30 +0100
committerDamien George <damien.p.george@gmail.com>2014-08-27 09:20:30 +0100
commita75b02ea9be41c27b87fd80ad37e7c26b4583fad (patch)
treea167161db4f7b57d23445314bd0f07bc139ac271 /py/objstr.c
parentad4c014d461cf325712d961c547f461746f52408 (diff)
py: Improve efficiency of MP_OBJ_IS_STR_OR_BYTES.
Saves ROM (16 on stmhal, 240 on 64-bit unix) and should be quicker since there is 1 less branch.
Diffstat (limited to 'py/objstr.c')
-rw-r--r--py/objstr.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/py/objstr.c b/py/objstr.c
index f38532963..366ba8816 100644
--- a/py/objstr.c
+++ b/py/objstr.c
@@ -247,6 +247,9 @@ STATIC const byte *find_subbytes(const byte *haystack, mp_uint_t hlen, const byt
return NULL;
}
+// Note: this function is used to check if an object is a str or bytes, which
+// works because both those types use it as their binary_op method. Revisit
+// MP_OBJ_IS_STR_OR_BYTES if this fact changes.
mp_obj_t mp_obj_str_binary_op(int op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
GET_STR_DATA_LEN(lhs_in, lhs_data, lhs_len);
mp_obj_type_t *lhs_type = mp_obj_get_type(lhs_in);