From 3b9f725654833ed39d7329fe1446842424768bdc Mon Sep 17 00:00:00 2001 From: cloudwalk Date: Sun, 9 May 2021 04:45:06 +0000 Subject: [PATCH] Optimize FS_FileExtension (cherry picked from commit f7c1ec5c94e7356ac7ab9061c3c1f6fac6010336) git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@13131 d7cf8633-e32d-0410-b094-e92efae38249 --- fs.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/fs.c b/fs.c index a925ff31..c4ecfe28 100644 --- a/fs.c +++ b/fs.c @@ -1329,6 +1329,10 @@ const char *FS_FileExtension (const char *in) { const char *separator, *backslash, *colon, *dot; + dot = strrchr(in, '.'); + if (dot == NULL) + return ""; + separator = strrchr(in, '/'); backslash = strrchr(in, '\\'); if (!separator || separator < backslash) @@ -1337,8 +1341,7 @@ const char *FS_FileExtension (const char *in) if (!separator || separator < colon) separator = colon; - dot = strrchr(in, '.'); - if (dot == NULL || (separator && (dot < separator))) + if (separator && (dot < separator)) return ""; return dot + 1; -- 2.39.2