Skip to content

Commit e6fbee0

Browse files
committed
py/builtinhelp: Simplify code slightly by extracting object type.
Reduces code size by about 10 bytes.
1 parent da1c80d commit e6fbee0

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

py/builtinhelp.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -136,20 +136,19 @@ STATIC void mp_help_print_obj(const mp_obj_t obj) {
136136
}
137137
#endif
138138

139+
mp_obj_type_t *type = mp_obj_get_type(obj);
140+
139141
// try to print something sensible about the given object
140142
mp_print_str(MP_PYTHON_PRINTER, "object ");
141143
mp_obj_print(obj, PRINT_STR);
142-
mp_printf(MP_PYTHON_PRINTER, " is of type %s\n", mp_obj_get_type_str(obj));
144+
mp_printf(MP_PYTHON_PRINTER, " is of type %q\n", type->name);
143145

144146
mp_map_t *map = NULL;
145-
if (MP_OBJ_IS_TYPE(obj, &mp_type_module)) {
147+
if (type == &mp_type_module) {
146148
map = mp_obj_dict_get_map(mp_obj_module_get_globals(obj));
147149
} else {
148-
mp_obj_type_t *type;
149-
if (MP_OBJ_IS_TYPE(obj, &mp_type_type)) {
150-
type = obj;
151-
} else {
152-
type = mp_obj_get_type(obj);
150+
if (type == &mp_type_type) {
151+
type = MP_OBJ_TO_PTR(obj);
153152
}
154153
if (type->locals_dict != MP_OBJ_NULL && MP_OBJ_IS_TYPE(type->locals_dict, &mp_type_dict)) {
155154
map = mp_obj_dict_get_map(type->locals_dict);

0 commit comments

Comments
 (0)