Put seclist nodes in LevelPool memory

Replaces the old freelist solution with the LevelPool, which
dramatically reduces the number of allocations needed for mobj and
precip sector assignment. In measurement, this cuts down the time taken
for spawning precipitation by 50%.
This commit is contained in:
Eidolon 2024-10-20 17:15:13 -05:00
parent a816b93541
commit b8f334a83c

View file

@ -2776,7 +2776,7 @@ fixed_t P_GetThingStepUp(mobj_t *thing, fixed_t destX, fixed_t destY)
maxstep += abs(momentumzdelta); maxstep += abs(momentumzdelta);
// if (thing->player) // if (thing->player)
// CONS_Printf(" %d = %d\n", momentumzdelta, maxstep); // CONS_Printf(" %d = %d\n", momentumzdelta, maxstep);
} }
if (P_MobjTouchingSectorSpecialFlag(thing, SSF_DOUBLESTEPUP) if (P_MobjTouchingSectorSpecialFlag(thing, SSF_DOUBLESTEPUP)
@ -2979,7 +2979,7 @@ increment_move
} }
else if (g_tm.floorz - g_tm.dropoffz > maxstep) else if (g_tm.floorz - g_tm.dropoffz > maxstep)
return false; // don't stand over a dropoff return false; // don't stand over a dropoff
} }
} }
} while (tryx != x || tryy != y); } while (tryx != x || tryy != y);
@ -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