diff options
author | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2014-02-10 07:10:55 +0200 |
---|---|---|
committer | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2014-02-10 07:13:32 +0200 |
commit | ac0134d427677438ec07f76f9b28b3f514cebde7 (patch) | |
tree | 6d2b9c21d6cdb6ec43373473a38dac9562fd3830 /py/objlist.c | |
parent | 624eff6a8a948c5ffa7c7d17fab69b3739f2e711 (diff) | |
download | micropython-ac0134d427677438ec07f76f9b28b3f514cebde7.tar.gz micropython-ac0134d427677438ec07f76f9b28b3f514cebde7.zip |
Factor out mp_seq_count_obj() and implement tuple.count().
Diffstat (limited to 'py/objlist.c')
-rw-r--r-- | py/objlist.c | 9 |
1 files changed, 1 insertions, 8 deletions
diff --git a/py/objlist.c b/py/objlist.c index 0c6525be8a..4e8944d35e 100644 --- a/py/objlist.c +++ b/py/objlist.c @@ -260,14 +260,7 @@ static mp_obj_t list_copy(mp_obj_t self_in) { static mp_obj_t list_count(mp_obj_t self_in, mp_obj_t value) { assert(MP_OBJ_IS_TYPE(self_in, &list_type)); mp_obj_list_t *self = self_in; - int count = 0; - for (int i = 0; i < self->len; i++) { - if (mp_obj_equal(self->items[i], value)) { - count++; - } - } - - return mp_obj_new_int(count); + return mp_seq_count_obj(self->items, self->len, value); } static mp_obj_t list_index(uint n_args, const mp_obj_t *args) { |