extmod/vfs: Add fast path for stating VfsPosix filesystem.

pull/3846/head
Damien George 2018-06-06 13:12:23 +10:00
rodzic a93144cb65
commit d4ce57e4e3
1 zmienionych plików z 10 dodań i 1 usunięć

Wyświetl plik

@ -34,6 +34,9 @@
#if MICROPY_VFS
#if MICROPY_VFS_POSIX
#include "extmod/vfs_posix.h"
#endif
#if MICROPY_VFS_FAT
#include "extmod/vfs_fat.h"
#endif
@ -124,8 +127,14 @@ mp_import_stat_t mp_vfs_import_stat(const char *path) {
if (vfs == MP_VFS_NONE || vfs == MP_VFS_ROOT) {
return MP_IMPORT_STAT_NO_EXIST;
}
// Fast paths for known VFS types
#if MICROPY_VFS_POSIX
if (mp_obj_get_type(vfs->obj) == &mp_type_vfs_posix) {
return mp_vfs_posix_import_stat(MP_OBJ_TO_PTR(vfs->obj), path_out);
}
#endif
#if MICROPY_VFS_FAT
// fast paths for known VFS types
if (mp_obj_get_type(vfs->obj) == &mp_fat_vfs_type) {
return fat_vfs_import_stat(MP_OBJ_TO_PTR(vfs->obj), path_out);
}