Skip to content

Commit

Permalink
Improve chunk id search (#471)
Browse files Browse the repository at this point in the history
If we move UNKN_ID to the bottom of the enum, in the for() cycle inside chunkid() if the value is not found then the "i" variable will be already UNKN_ID.
  • Loading branch information
carlo-bramini authored and derselbst committed Nov 25, 2018
1 parent 36da011 commit b8b41f7
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/sfloader/fluid_sffile.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
/* sf file chunk IDs */
enum
{
UNKN_ID,
RIFF_ID,
LIST_ID,
SFBK_ID,
Expand Down Expand Up @@ -74,7 +73,9 @@ enum
IMOD_ID,
IGEN_ID, /* instrument ids */
SHDR_ID, /* sample info */
SM24_ID
SM24_ID,

UNKN_ID
};

/*
Expand Down Expand Up @@ -517,11 +518,12 @@ static int chunkid(uint32_t id)
{
if(*p == id)
{
return (i + 1);
break;
}
}

return UNKN_ID;
/* Return chunk id or UNKN_ID if not found */
return i;
}

static int load_header(SFData *sf)
Expand Down

0 comments on commit b8b41f7

Please sign in to comment.