Skip to content

Commit a642241

Browse files
committed
py/builtinimport: Adjust if-block order in find_file to clean up #if's.
1 parent 2b50afa commit a642241

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

py/builtinimport.c

+5-7
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,7 @@ STATIC mp_import_stat_t find_file(const char *file_str, uint file_len, vstr_t *d
102102
mp_obj_t *path_items;
103103
mp_obj_list_get(mp_sys_path, &path_num, &path_items);
104104

105-
if (path_num == 0) {
106-
#endif
107-
// mp_sys_path is empty, so just use the given file name
108-
vstr_add_strn(dest, file_str, file_len);
109-
return stat_dir_or_file(dest);
110-
#if MICROPY_PY_SYS
111-
} else {
105+
if (path_num != 0) {
112106
// go through each path looking for a directory or file
113107
for (size_t i = 0; i < path_num; i++) {
114108
vstr_reset(dest);
@@ -129,6 +123,10 @@ STATIC mp_import_stat_t find_file(const char *file_str, uint file_len, vstr_t *d
129123
return MP_IMPORT_STAT_NO_EXIST;
130124
}
131125
#endif
126+
127+
// mp_sys_path is empty, so just use the given file name
128+
vstr_add_strn(dest, file_str, file_len);
129+
return stat_dir_or_file(dest);
132130
}
133131

134132
#if MICROPY_MODULE_FROZEN_STR || MICROPY_ENABLE_COMPILER

0 commit comments

Comments
 (0)