diff options
author | Krzysztof Blazewicz <blazewicz.krzysztof@gmail.com> | 2017-03-04 12:29:20 +0100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2017-03-07 16:48:16 +1100 |
commit | 7e480e8a30e5e293586bd4806f02a481a08648ca (patch) | |
tree | 86862127caf3443c4ce19418a2f4af971181eb22 /py/objstr.c | |
parent | 1215dc47e2eb8ad3d70e3f1aa1a36a98024019a2 (diff) | |
download | micropython-7e480e8a30e5e293586bd4806f02a481a08648ca.tar.gz micropython-7e480e8a30e5e293586bd4806f02a481a08648ca.zip |
py: Use mp_obj_get_array where sequence may be a tuple or a list.
Diffstat (limited to 'py/objstr.c')
-rw-r--r-- | py/objstr.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/py/objstr.c b/py/objstr.c index c137afe673..17d06f88e8 100644 --- a/py/objstr.c +++ b/py/objstr.c @@ -430,16 +430,13 @@ STATIC mp_obj_t str_join(mp_obj_t self_in, mp_obj_t arg) { // process args mp_uint_t seq_len; mp_obj_t *seq_items; - if (MP_OBJ_IS_TYPE(arg, &mp_type_tuple)) { - mp_obj_tuple_get(arg, &seq_len, &seq_items); - } else { - if (!MP_OBJ_IS_TYPE(arg, &mp_type_list)) { - // arg is not a list, try to convert it to one - // TODO: Try to optimize? - arg = mp_type_list.make_new(&mp_type_list, 1, 0, &arg); - } - mp_obj_list_get(arg, &seq_len, &seq_items); + + if (!MP_OBJ_IS_TYPE(arg, &mp_type_list) && !MP_OBJ_IS_TYPE(arg, &mp_type_tuple)) { + // arg is not a list nor a tuple, try to convert it to a list + // TODO: Try to optimize? + arg = mp_type_list.make_new(&mp_type_list, 1, 0, &arg); } + mp_obj_get_array(arg, &seq_len, &seq_items); // count required length size_t required_len = 0; |