diff options
author | Damien George <damien.p.george@gmail.com> | 2018-07-08 21:31:09 +1000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2018-07-08 21:31:09 +1000 |
commit | a6ea6b08bc6b27fa4776e709537ce13a9950733e (patch) | |
tree | 9ab2671f2b8482ad699eab9d6368066061ae598c /py | |
parent | 106e594580d4de2d680c7ceefc7a1c331b4de3dd (diff) | |
download | micropython-a6ea6b08bc6b27fa4776e709537ce13a9950733e.tar.gz micropython-a6ea6b08bc6b27fa4776e709537ce13a9950733e.zip |
py: Simplify some cases of accessing the map of module and type dict.
mp_obj_module_get_globals() returns a mp_obj_dict_t*, and type->locals_dict
is a mp_obj_dict_t*, so access the map entry of the dict directly instead
of needing to cast this mp_obj_dict_t* up to an object and then calling the
mp_obj_dict_get_map() helper function.
Diffstat (limited to 'py')
-rw-r--r-- | py/builtinhelp.c | 6 | ||||
-rw-r--r-- | py/runtime.c | 2 |
2 files changed, 4 insertions, 4 deletions
diff --git a/py/builtinhelp.c b/py/builtinhelp.c index 6c2c3b92c0..b36f4c9d33 100644 --- a/py/builtinhelp.c +++ b/py/builtinhelp.c @@ -145,13 +145,13 @@ STATIC void mp_help_print_obj(const mp_obj_t obj) { mp_map_t *map = NULL; if (type == &mp_type_module) { - map = mp_obj_dict_get_map(mp_obj_module_get_globals(obj)); + map = &mp_obj_module_get_globals(obj)->map; } else { if (type == &mp_type_type) { type = MP_OBJ_TO_PTR(obj); } - if (type->locals_dict != MP_OBJ_NULL && MP_OBJ_IS_TYPE(type->locals_dict, &mp_type_dict)) { - map = mp_obj_dict_get_map(type->locals_dict); + if (type->locals_dict != NULL) { + map = &type->locals_dict->map; } } if (map != NULL) { diff --git a/py/runtime.c b/py/runtime.c index a2dac46a42..33ef9da4bd 100644 --- a/py/runtime.c +++ b/py/runtime.c @@ -1394,7 +1394,7 @@ void mp_import_all(mp_obj_t module) { DEBUG_printf("import all %p\n", module); // TODO: Support __all__ - mp_map_t *map = mp_obj_dict_get_map(MP_OBJ_FROM_PTR(mp_obj_module_get_globals(module))); + mp_map_t *map = &mp_obj_module_get_globals(module)->map; for (size_t i = 0; i < map->alloc; i++) { if (MP_MAP_SLOT_IS_FILLED(map, i)) { qstr name = MP_OBJ_QSTR_VALUE(map->table[i].key); |