diff options
author | John R. Lenton <jlenton@gmail.com> | 2014-01-13 19:52:28 +0000 |
---|---|---|
committer | John R. Lenton <jlenton@gmail.com> | 2014-01-13 19:52:28 +0000 |
commit | 2ded68db77d92f4f277ae688c22ac0be32dc4f31 (patch) | |
tree | edd62f1099b30daed97784a3a3b37e508761a4dc /py/builtin.c | |
parent | 5c7683955994b965270598559e979c581ddc1950 (diff) |
Cleaned up sorted() as per Damien's suggestions.
Diffstat (limited to 'py/builtin.c')
-rw-r--r-- | py/builtin.c | 9 |
1 files changed, 1 insertions, 8 deletions
diff --git a/py/builtin.c b/py/builtin.c index f73d41b0d..2d61cd603 100644 --- a/py/builtin.c +++ b/py/builtin.c @@ -297,7 +297,6 @@ mp_obj_t mp_builtin_sum(int n_args, const mp_obj_t *args) { return value; } -extern mp_obj_t list_sort(mp_obj_t args, mp_map_t *kwargs); static mp_obj_t mp_builtin_sorted(mp_obj_t args, mp_map_t *kwargs) { mp_obj_t *args_items = NULL; uint args_len = 0; @@ -309,13 +308,7 @@ static mp_obj_t mp_builtin_sorted(mp_obj_t args, mp_map_t *kwargs) { nlr_jump(mp_obj_new_exception_msg(MP_QSTR_TypeError, "must use keyword argument for key function")); } - mp_obj_t iterable = rt_getiter(args_items[0]); - mp_obj_t self = rt_build_list(0, NULL); - mp_obj_t item; - while ((item = rt_iternext(iterable)) != mp_const_stop_iteration) { - rt_list_append(self, item); - } - + mp_obj_t self = list_type.make_new((mp_obj_t)&list_type, 1, args_items); mp_obj_t new_args = rt_build_tuple(1, &self); list_sort(new_args, kwargs); |