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:
parent
a4b073a76b
commit
4f6ebff439
2 changed files with 11 additions and 7 deletions
|
|
@ -1362,16 +1362,18 @@ int musicdef_volume;
|
|||
//
|
||||
static 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;
|
||||
|
|
@ -1433,6 +1435,7 @@ ReadMusicDefFields
|
|||
|
||||
STRBUFCPY(def->name, value);
|
||||
strlwr(def->name);
|
||||
def->hash = quickncasehash (def->name, 6);
|
||||
def->volume = DEFAULT_MUSICDEF_VOLUME;
|
||||
|
||||
def->next = musicdefstart;
|
||||
|
|
|
|||
|
|
@ -168,6 +168,7 @@ boolean S_SpeedMusic(float speed);
|
|||
typedef struct musicdef_s
|
||||
{
|
||||
char name[7];
|
||||
UINT32 hash;
|
||||
char *title;
|
||||
char *author;
|
||||
char *source;
|
||||
|
|
|
|||
Loading…
Reference in a new issue