From b67f6c21f2c83fa66c66bcb2ea6135ee21142c4e Mon Sep 17 00:00:00 2001 From: Nicky Date: Mon, 7 Jan 2013 11:51:25 +0100 Subject: [PATCH] Add operator new/delete with object pool to LLViewerPart. --- indra/newview/llviewerpartsim.cpp | 20 ++++++++++++++++++++ indra/newview/llviewerpartsim.h | 5 +++++ 2 files changed, 25 insertions(+) diff --git a/indra/newview/llviewerpartsim.cpp b/indra/newview/llviewerpartsim.cpp index 345023dbfa..0de442ca38 100644 --- a/indra/newview/llviewerpartsim.cpp +++ b/indra/newview/llviewerpartsim.cpp @@ -41,6 +41,8 @@ #include "llspatialpartition.h" #include "llvovolume.h" +#include "ndobjectpool.h" // For operator new/delete + const F32 PART_SIM_BOX_SIDE = 16.f; const F32 PART_SIM_BOX_OFFSET = 0.5f*PART_SIM_BOX_SIDE; const F32 PART_SIM_BOX_RAD = 0.5f*F_SQRT3*PART_SIM_BOX_SIDE; @@ -859,3 +861,21 @@ void LLViewerPartSim::clearParticlesByOwnerID(const LLUUID& task_id) } } } + +// Object pool for LLViewerPart + +// Assume this is singlethreaded (nd::locks::NoLock) 16 byte aligned and allocate 128 objects per chunk +nd::objectpool::ObjectPool< LLViewerPart, nd::locks::NoLock, 16, 128 > sViewerpartPool; + +void* LLViewerPart::operator new(size_t size) +{ + llassert_always( size == sizeof(LLViewerPart) ); + return sViewerpartPool.allocMemoryForObject(); +} + +void LLViewerPart::operator delete(void* ptr) +{ + sViewerpartPool.freeMemoryOfObject( ptr ); +} + +// \ No newline at end of file diff --git a/indra/newview/llviewerpartsim.h b/indra/newview/llviewerpartsim.h index c9959c63ec..0f7a1eeb41 100644 --- a/indra/newview/llviewerpartsim.h +++ b/indra/newview/llviewerpartsim.h @@ -76,6 +76,11 @@ public: LLVector2 mScale; static U32 sNextPartID; + + // Object pool for LLViewerPart + void* operator new(size_t size); + void operator delete(void* ptr); + // };