Browse Source

py/objdict: Make mp_obj_dict_get_map an inline function.

It's a very simple function and saves code, and improves efficiency, by
being inline.  Note that this is an auxiliary helper function and so
doesn't need mp_check_self -- that's used for functions that can be
accessed directly from Python code (eg from a method table).
pull/3937/head
Damien George 6 years ago
parent
commit
d9cdb880ff
  1. 4
      py/obj.h
  2. 6
      py/objdict.c

4
py/obj.h

@ -758,7 +758,9 @@ size_t mp_obj_dict_len(mp_obj_t self_in);
mp_obj_t mp_obj_dict_get(mp_obj_t self_in, mp_obj_t index);
mp_obj_t mp_obj_dict_store(mp_obj_t self_in, mp_obj_t key, mp_obj_t value);
mp_obj_t mp_obj_dict_delete(mp_obj_t self_in, mp_obj_t key);
mp_map_t *mp_obj_dict_get_map(mp_obj_t self_in);
static inline mp_map_t *mp_obj_dict_get_map(mp_obj_t dict) {
return &((mp_obj_dict_t*)MP_OBJ_TO_PTR(dict))->map;
}
// set
void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item);

6
py/objdict.c

@ -600,9 +600,3 @@ mp_obj_t mp_obj_dict_delete(mp_obj_t self_in, mp_obj_t key) {
dict_get_helper(2, args, MP_MAP_LOOKUP_REMOVE_IF_FOUND);
return self_in;
}
mp_map_t *mp_obj_dict_get_map(mp_obj_t self_in) {
mp_check_self(MP_OBJ_IS_DICT_TYPE(self_in));
mp_obj_dict_t *self = MP_OBJ_TO_PTR(self_in);
return &self->map;
}

Loading…
Cancel
Save