mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-15 09:11:48 +00:00
Don't realloc twice when adding to the taggroup
This commit is contained in:
parent
828d7e71ce
commit
ae663e7247
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++)
|
||||
if (group->elements[i] > id)
|
||||
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->elements = Z_Realloc(group->elements, group->count * sizeof(size_t), PU_LEVEL, NULL);
|
||||
group->elements[i] = id;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue