py/objmodule: Make mp_obj_module_get_globals an inline function.
Because this function is simple it saves code size to have it inlined. Being an auxiliary helper function (and only used in the py/ core) the argument should always be an mp_obj_module_t*, so there's no need for the assert (and having it would require including assert.h in obj.h).
This commit is contained in:
parent
d9cdb880ff
commit
4cd853fbd2
4
py/obj.h
4
py/obj.h
|
@ -804,7 +804,9 @@ typedef struct _mp_obj_module_t {
|
||||||
mp_obj_base_t base;
|
mp_obj_base_t base;
|
||||||
mp_obj_dict_t *globals;
|
mp_obj_dict_t *globals;
|
||||||
} mp_obj_module_t;
|
} mp_obj_module_t;
|
||||||
mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in);
|
static inline mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t module) {
|
||||||
|
return ((mp_obj_module_t*)MP_OBJ_TO_PTR(module))->globals;
|
||||||
|
}
|
||||||
// check if given module object is a package
|
// check if given module object is a package
|
||||||
bool mp_obj_is_package(mp_obj_t module);
|
bool mp_obj_is_package(mp_obj_t module);
|
||||||
|
|
||||||
|
|
|
@ -122,12 +122,6 @@ mp_obj_t mp_obj_new_module(qstr module_name) {
|
||||||
return MP_OBJ_FROM_PTR(o);
|
return MP_OBJ_FROM_PTR(o);
|
||||||
}
|
}
|
||||||
|
|
||||||
mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in) {
|
|
||||||
assert(MP_OBJ_IS_TYPE(self_in, &mp_type_module));
|
|
||||||
mp_obj_module_t *self = MP_OBJ_TO_PTR(self_in);
|
|
||||||
return self->globals;
|
|
||||||
}
|
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
// Global module table and related functions
|
// Global module table and related functions
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue