Commit 7d21d516 authored by John R. Lenton's avatar John R. Lenton
Browse files

make dict_len use the map's used count

parent 4ce6cead
......@@ -128,12 +128,12 @@ static mp_obj_t dict_clear(mp_obj_t self_in) {
return mp_const_none;
}
static MP_DEFINE_CONST_FUN_OBJ_1(dict_clear_obj, dict_clear);
/******************************************************************************/
/* dict constructors & etc */
static MP_DEFINE_CONST_FUN_OBJ_1(dict_clear_obj, dict_clear);
const mp_obj_type_t dict_type = {
{ &mp_const_type },
"dict",
......@@ -156,13 +156,7 @@ mp_obj_t mp_obj_new_dict(int n_args) {
uint mp_obj_dict_len(mp_obj_t self_in) {
mp_obj_dict_t *self = self_in;
uint len = 0;
for (int i = 0; i < self->map.alloc; i++) {
if (self->map.table[i].key != NULL) {
len += 1;
}
}
return len;
return self->map.used;
}
mp_obj_t mp_obj_dict_store(mp_obj_t self_in, mp_obj_t key, mp_obj_t value) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment