mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-11 15:22:16 +00:00
- use a memory arena to allocate msecnodes.
These are rather small and extremely frequently allocated, so they are prime candidates for memory arena, because it not only avoids fragmentation and internal overhead due to mass allocation of small memory blocks but it also makes it a lot faster to free the memory when finishing a level.
This commit is contained in:
parent
ed25cf61c5
commit
c52bc06e9b
2 changed files with 8 additions and 12 deletions
|
@ -24,6 +24,7 @@
|
||||||
#include "r_state.h"
|
#include "r_state.h"
|
||||||
#include "p_maputl.h"
|
#include "p_maputl.h"
|
||||||
#include "p_blockmap.h"
|
#include "p_blockmap.h"
|
||||||
|
#include "memarena.h"
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
// phares 3/21/98
|
// phares 3/21/98
|
||||||
|
@ -32,6 +33,7 @@
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
|
|
||||||
msecnode_t *headsecnode = NULL;
|
msecnode_t *headsecnode = NULL;
|
||||||
|
FMemArena secnodearena;
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
//
|
//
|
||||||
|
@ -53,7 +55,8 @@ msecnode_t *P_GetSecnode()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
node = (msecnode_t *)M_Malloc(sizeof(*node));
|
node =
|
||||||
|
node = (msecnode_t *)secnodearena.Alloc(sizeof(*node));
|
||||||
}
|
}
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3552,6 +3552,7 @@ void P_FreeLevelData ()
|
||||||
P_ClearUDMFKeys();
|
P_ClearUDMFKeys();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern FMemArena secnodearena;
|
||||||
extern msecnode_t *headsecnode;
|
extern msecnode_t *headsecnode;
|
||||||
|
|
||||||
void P_FreeExtraLevelData()
|
void P_FreeExtraLevelData()
|
||||||
|
@ -3569,19 +3570,11 @@ void P_FreeExtraLevelData()
|
||||||
}
|
}
|
||||||
FBlockNode::FreeBlocks = NULL;
|
FBlockNode::FreeBlocks = NULL;
|
||||||
}
|
}
|
||||||
{
|
secnodearena.FreeAllBlocks();
|
||||||
msecnode_t *node = headsecnode;
|
headsecnode = nullptr;
|
||||||
|
|
||||||
while (node != NULL)
|
|
||||||
{
|
|
||||||
msecnode_t *next = node->m_snext;
|
|
||||||
M_Free (node);
|
|
||||||
node = next;
|
|
||||||
}
|
|
||||||
headsecnode = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// P_SetupLevel
|
// P_SetupLevel
|
||||||
//
|
//
|
||||||
|
|
Loading…
Reference in a new issue