From: terencehill Date: Thu, 6 May 2021 08:42:58 +0000 (+0200) Subject: Optimize FS_FileExtension X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=f7c1ec5c94e7356ac7ab9061c3c1f6fac6010336;p=xonotic%2Fdarkplaces.git Optimize FS_FileExtension --- 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;