From d4ce57e4e320a717db1a231f2e6c1e92afaafde0 Mon Sep 17 00:00:00 2001 From: Damien George Date: Wed, 6 Jun 2018 13:12:23 +1000 Subject: [PATCH] extmod/vfs: Add fast path for stating VfsPosix filesystem. --- extmod/vfs.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/extmod/vfs.c b/extmod/vfs.c index 7298edab17..96d5019b37 100644 --- a/extmod/vfs.c +++ b/extmod/vfs.c @@ -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); }