summaryrefslogtreecommitdiffstatshomepage
path: root/py
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2018-07-08 22:23:57 +1000
committerDamien George <damien.p.george@gmail.com>2018-07-08 22:27:05 +1000
commitd9cdb880ff9588c7e7f9c9374d2b333187cb990f (patch)
tree1c3cc0bc5affe76d011a52e9074f64ebc36292b3 /py
parent3503f9626abbcbd59fe34009eef8f401c61f2b3d (diff)
downloadmicropython-d9cdb880ff9588c7e7f9c9374d2b333187cb990f.tar.gz
micropython-d9cdb880ff9588c7e7f9c9374d2b333187cb990f.zip
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).
Diffstat (limited to 'py')
-rw-r--r--py/obj.h4
-rw-r--r--py/objdict.c6
2 files changed, 3 insertions, 7 deletions
diff --git a/py/obj.h b/py/obj.h
index 0ff91e81f7..3dacf91247 100644
--- a/py/obj.h
+++ b/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);
diff --git a/py/objdict.c b/py/objdict.c
index c0647067a1..9a6fd74e2a 100644
--- a/py/objdict.c
+++ b/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;
-}