From 1b7ceada592c7e4f56578142b1fe2b7e0ad2f208 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Sat, 2 Nov 2024 14:05:47 +0000 Subject: [PATCH] FS_Dir_f little optimisation. --- src/common/filesystem.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/common/filesystem.c b/src/common/filesystem.c index 6e15cdbc..ece3ba97 100644 --- a/src/common/filesystem.c +++ b/src/common/filesystem.c @@ -1534,6 +1534,7 @@ FS_Dir_f(void) char **dirnames; /* File list. */ char findname[1024]; /* File search path and pattern. */ char *path = NULL; /* Search path. */ + char *lastsep; char wildcard[1024] = "*.*"; /* File pattern. */ int i; /* Loop counter. */ int ndirs; /* Number of files in list. */ @@ -1555,9 +1556,10 @@ FS_Dir_f(void) { for (i = 0; i < ndirs - 1; i++) { - if (strrchr(dirnames[i], '/')) + lastsep = strrchr(dirnames[i], '/'); + if (lastsep) { - Com_Printf("%s\n", strrchr(dirnames[i], '/') + 1); + Com_Printf("%s\n", lastsep + 1); } else {