mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Tier1: optimize V_UnqualifiedFileName()
If we are going to do a strlen, then check the chars from the start
This commit is contained in:
parent
d22800b43b
commit
172ac8f313
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user