Speedup SF2 loading by using prepend instead of append on samples

Using prepend both in sffile and defsfont reduces insert complexity
to O(1) and does not affect the final order of the sample list, as
the reversed order of the samples in sffile is reversed again in
defsfont.
This commit is contained in:
Marcus Weseloh 2021-03-28 15:00:25 +02:00
parent 0f8e2c7fde
commit 5ebd4d3d26
2 changed files with 2 additions and 2 deletions

View file

@ -562,7 +562,7 @@ err_exit:
*/
int fluid_defsfont_add_sample(fluid_defsfont_t *defsfont, fluid_sample_t *sample)
{
defsfont->sample = fluid_list_append(defsfont->sample, sample);
defsfont->sample = fluid_list_prepend(defsfont->sample, sample);
return FLUID_OK;
}

View file

@ -2024,7 +2024,7 @@ static int load_shdr(SFData *sf, unsigned int size)
}
p->idx = i;
sf->sample = fluid_list_append(sf->sample, p);
sf->sample = fluid_list_prepend(sf->sample, p);
READSTR(sf, &p->name);
READD(sf, p->start);
READD(sf, p->end);