From: cloudwalk Date: Sun, 9 May 2021 04:45:06 +0000 (+0000) Subject: Optimize FS_FileExtension X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=3b9f725654833ed39d7329fe1446842424768bdc;p=xonotic%2Fdarkplaces.git Optimize FS_FileExtension (cherry picked from commit f7c1ec5c94e7356ac7ab9061c3c1f6fac6010336) git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@13131 d7cf8633-e32d-0410-b094-e92efae38249 --- 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;