8000 py/builtinhelp: Simplify code slightly by extracting object type. · devmonkZA/micropython@e6fbee0 · GitHub
[go: up one dir, main page]

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
< 4C6D td data-grid-cell-id="diff-c81891eaf428ec5c32ee8b380bfe89f5a86c08d8008202c090fd9731ee1c32c7-152-151-2" data-line-anchor="diff-c81891eaf428ec5c32ee8b380bfe89f5a86c08d8008202c090fd9731ee1c32c7R151" data-selected="false" role="gridcell" style="background-color:var(--diffBlob-additionLine-bgColor, var(--diffBlob-addition-bgColor-line));padding-right:24px" tabindex="-1" valign="top" class="focusable-grid-cell diff-text-cell right-side-diff-cell left-side">+
type = MP_OBJ_TO_PTR(obj);
Original file line numberDiff line numberDiff line change
@@ -136,20 +136,19 @@ STATIC void mp_help 8000 _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
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)
0