Merge branch 'sec-taglists-levelpool' into 'master'

Put seclist and taglist nodes in LevelPool memory

See merge request KartKrew/Kart!2488
This commit is contained in:
Eidolon 2024-11-02 18:55:25 +00:00
commit b711c82237
2 changed files with 21 additions and 33 deletions

View file

@ -4642,13 +4642,8 @@ boolean P_CheckSector(sector_t *sector, boolean crunch)
Lots of new Boom functions that work faster and add functionality. Lots of new Boom functions that work faster and add functionality.
*/ */
static msecnode_t *headsecnode = NULL;
static mprecipsecnode_t *headprecipsecnode = NULL;
void P_Initsecnode(void) void P_Initsecnode(void)
{ {
headsecnode = NULL;
headprecipsecnode = NULL;
} }
// P_GetSecnode() retrieves a node from the freelist. The calling routine // P_GetSecnode() retrieves a node from the freelist. The calling routine
@ -4656,45 +4651,25 @@ void P_Initsecnode(void)
static msecnode_t *P_GetSecnode(void) static msecnode_t *P_GetSecnode(void)
{ {
msecnode_t *node; return Z_LevelPoolCalloc(sizeof(msecnode_t));
if (headsecnode)
{
node = headsecnode;
headsecnode = headsecnode->m_thinglist_next;
}
else
node = Z_Calloc(sizeof (*node), PU_LEVEL, NULL);
return node;
} }
static mprecipsecnode_t *P_GetPrecipSecnode(void) static mprecipsecnode_t *P_GetPrecipSecnode(void)
{ {
mprecipsecnode_t *node; return Z_LevelPoolCalloc(sizeof(mprecipsecnode_t));
if (headprecipsecnode)
{
node = headprecipsecnode;
headprecipsecnode = headprecipsecnode->m_thinglist_next;
}
else
node = Z_Calloc(sizeof (*node), PU_LEVEL, NULL);
return node;
} }
// P_PutSecnode() returns a node to the freelist. // P_PutSecnode() returns a node to the freelist.
static inline void P_PutSecnode(msecnode_t *node) static inline void P_PutSecnode(msecnode_t *node)
{ {
node->m_thinglist_next = headsecnode; Z_LevelPoolFree(node, sizeof(msecnode_t));
headsecnode = node;
} }
// Tails 08-25-2002 // Tails 08-25-2002
static inline void P_PutPrecipSecnode(mprecipsecnode_t *node) static inline void P_PutPrecipSecnode(mprecipsecnode_t *node)
{ {
node->m_thinglist_next = headprecipsecnode; Z_LevelPoolFree(node, sizeof(mprecipsecnode_t));
headprecipsecnode = node;
} }
// P_AddSecnode() searches the current list to see if this sector is // P_AddSecnode() searches the current list to see if this sector is

View file

@ -31,9 +31,18 @@ taggroup_t* tags_lines[MAXTAGS + 1];
/// \warning This does not rebuild the global taggroups, which are used for iteration. /// \warning This does not rebuild the global taggroups, which are used for iteration.
void Tag_Add (taglist_t* list, const mtag_t tag) void Tag_Add (taglist_t* list, const mtag_t tag)
{ {
mtag_t *oldlist;
mtag_t *newlist;
if (Tag_Find(list, tag)) if (Tag_Find(list, tag))
return; return;
list->tags = Z_Realloc(list->tags, (list->count + 1) * sizeof(mtag_t), PU_LEVEL, NULL); oldlist = list->tags;
newlist = Z_LevelPoolMalloc((list->count + 1) * sizeof(mtag_t));
if (oldlist)
{
memcpy(newlist, oldlist, list->count * sizeof(mtag_t));
Z_LevelPoolFree(oldlist, list->count * sizeof(mtag_t));
}
list->tags = newlist;
list->tags[list->count++] = tag; list->tags[list->count++] = tag;
} }
@ -45,13 +54,17 @@ void Tag_Remove(taglist_t* list, const mtag_t tag)
for (i = 0; i < list->count; i++) for (i = 0; i < list->count; i++)
{ {
mtag_t *newlist;
if (list->tags[i] != tag) if (list->tags[i] != tag)
continue; continue;
for (; i+1 < list->count; i++) for (; i+1 < list->count; i++)
list->tags[i] = list->tags[i+1]; list->tags[i] = list->tags[i+1];
list->tags = Z_Realloc(list->tags, (list->count - 1) * sizeof(mtag_t), PU_LEVEL, NULL); newlist = Z_LevelPoolMalloc((list->count - 1) * sizeof(mtag_t));
memcpy(newlist, list->tags, (list->count) * sizeof(mtag_t));
Z_LevelPoolFree(list->tags, (list->count) * sizeof(mtag_t));
list->tags = newlist;
return; return;
} }
} }