From c52bc06e9bdbacb0a9f80e9caa889438437d904f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 6 Jan 2017 13:09:58 +0100 Subject: [PATCH] - 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. --- src/p_secnodes.cpp | 5 ++++- src/p_setup.cpp | 15 ++++----------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/p_secnodes.cpp b/src/p_secnodes.cpp index 14d354a7f8..38a9a5babd 100644 --- a/src/p_secnodes.cpp +++ b/src/p_secnodes.cpp @@ -24,6 +24,7 @@ #include "r_state.h" #include "p_maputl.h" #include "p_blockmap.h" +#include "memarena.h" //============================================================================= // phares 3/21/98 @@ -32,6 +33,7 @@ //============================================================================= msecnode_t *headsecnode = NULL; +FMemArena secnodearena; //============================================================================= // @@ -53,7 +55,8 @@ msecnode_t *P_GetSecnode() } else { - node = (msecnode_t *)M_Malloc(sizeof(*node)); + node = + node = (msecnode_t *)secnodearena.Alloc(sizeof(*node)); } return node; } diff --git a/src/p_setup.cpp b/src/p_setup.cpp index 00e854c54a..88694a8cfa 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -3552,6 +3552,7 @@ void P_FreeLevelData () P_ClearUDMFKeys(); } +extern FMemArena secnodearena; extern msecnode_t *headsecnode; void P_FreeExtraLevelData() @@ -3569,19 +3570,11 @@ void P_FreeExtraLevelData() } FBlockNode::FreeBlocks = NULL; } - { - msecnode_t *node = headsecnode; - - while (node != NULL) - { - msecnode_t *next = node->m_snext; - M_Free (node); - node = next; - } - headsecnode = NULL; - } + secnodearena.FreeAllBlocks(); + headsecnode = nullptr; } + // // P_SetupLevel //