From d40c5246e5f399e13d3dddac0179c75fecf72d5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Lu=C3=ADs=20Vaz=20Silva?= Date: Wed, 16 Apr 2025 23:20:14 -0300 Subject: [PATCH] optimize memory allocation --- src/playsim/a_dynlight.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/playsim/a_dynlight.cpp b/src/playsim/a_dynlight.cpp index d08ee10ec..4351592f7 100644 --- a/src/playsim/a_dynlight.cpp +++ b/src/playsim/a_dynlight.cpp @@ -95,7 +95,7 @@ static FDynamicLight *GetLight(FLevelLocals *Level) ret->mShadowmapIndex = 1024; ret->Level = Level; ret->Pos.X = -10000000; // not a valid coordinate. - if (!ret->touchlists) ret->touchlists = new FDynamicLightTouchLists; + ret->touchlists = new FDynamicLightTouchLists; return ret; } @@ -210,6 +210,8 @@ void FDynamicLight::ReleaseLight() else Level->lights = next; if (next != nullptr) next->prev = prev; next = prev = nullptr; + delete touchlists; + touchlists = nullptr; FreeList.Push(this); } @@ -722,8 +724,8 @@ void FDynamicLight::UnlinkLight () } } - delete touchlists; - touchlists = nullptr; + touchlists->flat_tlist.Clear(); + touchlists->wall_tlist.Clear(); shadowmapped = false; }