From 3c27384b6bec2612d834fce50e23d7da7c07c8db Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Mon, 13 Feb 2023 06:49:52 +0300 Subject: [PATCH] filesystem: speedup fs_ext_path case in FS_FindFile --- filesystem/filesystem.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/filesystem/filesystem.c b/filesystem/filesystem.c index f8fc449c..805bcf11 100644 --- a/filesystem/filesystem.c +++ b/filesystem/filesystem.c @@ -1709,17 +1709,21 @@ searchpath_t *FS_FindFile( const char *name, int *index, char *fixedname, size_t { static searchpath_t fs_directpath; - // clear old dir cache - if( fs_directpath.pfnClose ) - fs_directpath.pfnClose( &fs_directpath ); + // clear old dir cache, if needed + if( 0 != Q_strcmp( fs_directpath.filename, dirpath )) + { + if( fs_directpath.pfnClose ) + fs_directpath.pfnClose( &fs_directpath ); + FS_InitDirectorySearchpath( &fs_directpath, dirpath, 0 ); + } // just copy the name, we don't do case sensitivity fix there if( fixedname ) Q_strncpy( fixedname, name, len ); - FS_InitDirectorySearchpath( &fs_directpath, dirpath, 0 ); if( index != NULL ) *index = 0; + return &fs_directpath; } }