Slightly increase efficiency of osd_findsymbol() (this is the slow one that has to handle partial matches)

git-svn-id: https://svn.eduke32.com/eduke32@7008 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2018-10-07 05:20:47 +00:00
parent b0e0cfa2c9
commit 39c0c93615

View file

@ -1736,7 +1736,7 @@ static char *strtoken(char *s, char **ptrptr, int32_t *restart)
if (!p) return NULL; if (!p) return NULL;
// eat up any leading whitespace // eat up any leading whitespace
while (*p != 0 && *p != ';' && *p == ' ') p++; while (*p && *p == ' ') p++;
// a semicolon is an end of statement delimiter like a \0 is, so we signal // a semicolon is an end of statement delimiter like a \0 is, so we signal
// the caller to 'restart' for the rest of the string pointed at by *ptrptr // the caller to 'restart' for the rest of the string pointed at by *ptrptr
@ -1985,13 +1985,15 @@ static osdsymbol_t *osd_addsymbol(const char *pszName)
// //
// findsymbol() -- Finds a symbol, possibly partially named // findsymbol() -- Finds a symbol, possibly partially named
// //
static osdsymbol_t * osd_findsymbol(const char *pszName, osdsymbol_t *pSymbol) static osdsymbol_t * osd_findsymbol(const char * const pszName, osdsymbol_t *pSymbol)
{ {
if (!pSymbol) pSymbol = symbols; if (!pSymbol) pSymbol = symbols;
if (!pSymbol) return NULL; if (!pSymbol) return NULL;
int const nameLen = Bstrlen(pszName);
for (; pSymbol; pSymbol=pSymbol->next) for (; pSymbol; pSymbol=pSymbol->next)
if (pSymbol->func != OSD_UNALIASED && !Bstrncasecmp(pszName, pSymbol->name, Bstrlen(pszName))) return pSymbol; if (pSymbol->func != OSD_UNALIASED && !Bstrncasecmp(pszName, pSymbol->name, nameLen)) return pSymbol;
return NULL; return NULL;
} }