mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Don't realloc twice when adding to the taggroup
This commit is contained in:
parent
b21e3fc2bf
commit
1216108ea3
1 changed files with 6 additions and 7 deletions
|
|
@ -170,16 +170,15 @@ void Taggroup_Add (taggroup_t *garray[], const mtag_t tag, size_t id)
|
||||||
for (i = 0; i < group->count; i++)
|
for (i = 0; i < group->count; i++)
|
||||||
if (group->elements[i] > id)
|
if (group->elements[i] > id)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
group->elements = Z_Realloc(group->elements, (group->count + 1) * sizeof(size_t), PU_LEVEL, NULL);
|
|
||||||
|
|
||||||
// Offset existing elements to make room for the new one.
|
|
||||||
if (i < group->count)
|
|
||||||
memmove(&group->elements[i + 1], &group->elements[i], group->count - i);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
group->elements = Z_Realloc(group->elements, (group->count + 1) * sizeof(size_t), PU_LEVEL, NULL);
|
||||||
|
|
||||||
|
// Offset existing elements to make room for the new one.
|
||||||
|
if (i < group->count)
|
||||||
|
memmove(&group->elements[i + 1], &group->elements[i], group->count - i);
|
||||||
|
|
||||||
group->count++;
|
group->count++;
|
||||||
group->elements = Z_Realloc(group->elements, group->count * sizeof(size_t), PU_LEVEL, NULL);
|
|
||||||
group->elements[i] = id;
|
group->elements[i] = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue