musicdef_t: Add hash field

Slight optimisation for S_FindMusicDef, but will net us some big wins with our next feature.
This commit is contained in:
toaster 2023-03-22 23:34:01 +00:00
parent 7868f21dd0
commit cb4d9b527e
2 changed files with 11 additions and 7 deletions

View file

@ -1368,16 +1368,18 @@ struct cursongcredit cursongcredit; // Currently displayed song credit info
//
musicdef_t *S_FindMusicDef(const char *name)
{
musicdef_t *def = musicdefstart;
UINT32 hash = quickncasehash (name, 6);
musicdef_t *def;
while (def)
for (def = musicdefstart; def; def = def->next)
{
if (!stricmp(def->name, name))
{
return def;
}
if (hash != def->hash)
continue;
def = def->next;
if (stricmp(def->name, name))
continue;
return def;
}
return NULL;
@ -1439,6 +1441,7 @@ ReadMusicDefFields
STRBUFCPY(def->name, value);
strlwr(def->name);
def->hash = quickncasehash (def->name, 6);
def->volume = DEFAULT_MUSICDEF_VOLUME;
def->next = musicdefstart;

View file

@ -178,6 +178,7 @@ boolean S_SpeedMusic(float speed);
struct musicdef_t
{
char name[7];
UINT32 hash;
char *title;
char *author;
char *source;