Tier1: optimize V_UnqualifiedFileName()

If we are going to do a strlen, then check the chars from the start
This commit is contained in:
Kawe Mazidjatari 2024-02-07 14:30:37 +01:00
parent d22800b43b
commit 172ac8f313

View File

@ -1105,14 +1105,21 @@ size_t V_StripLastDir(char* dirName, size_t maxLen)
//-----------------------------------------------------------------------------
const char* V_UnqualifiedFileName(const char* in)
{
if (!in || !in[0])
return in;
Assert(in);
const char* out = in;
while (*in)
{
if (PATHSEPARATOR(*in))
{
// +1 to skip the slash
out = in + 1;;
}
in++;
}
// back up until the character after the first path separator we find,
// or the beginning of the string
const char* out = in + strlen(in) - 1;
while ((out > in) && (!PATHSEPARATOR(*(out - 1))))
out--;
return out;
}