Quote:
Originally Posted by Wanetrain
Replace the function with:
Code:
auto CWorld::_process() -> void
{
for( auto i = 0; i < std::extent<decltype(m_apObject)>::value; i++ )
{
const auto& pObj = m_apObject[ i ];
FLASSERT(pObj);
if( pObj && !pObj->IsDelete() && pObj->m_dwObjAryIdx != 0xffffffff )
{
pObj->Process();
}
}
}
You don't need m_dwObjNum.
If you have more Problems --> Pn.
|
I have several questions about that function.
1: Why auto return type if you specify -> void anyway?
2: Why increase the loop to iterate over the entire array every game loop? It increases CPU usage by a fuckton.
3: Why FLAssert(pObj) on objects that are then expected to be empty when nothing happens? Debug must go wild for you then.
4: Why use fancy std::extent and decltype when the array size is handled by a define you could just use there?
To me this looks like it doesnt do anything different than trigger asserts more and increase CPU usage on empty objects.
You might as well refactor a fixed size array to a vector implementation and iterate over that instead of iterating over 80k empty objects every time.