From a8d4e446696d885d7977836fa96968c5ba325b1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Tue, 8 Nov 2016 12:29:15 +0100 Subject: [PATCH] Sdk/World: Optimize updating dirty entities by removing a branch --- SDK/include/NDK/World.inl | 3 --- SDK/src/NDK/World.cpp | 9 ++++----- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/SDK/include/NDK/World.inl b/SDK/include/NDK/World.inl index b71df5926..212038625 100644 --- a/SDK/include/NDK/World.inl +++ b/SDK/include/NDK/World.inl @@ -253,9 +253,6 @@ namespace Ndk Update(); //< Update entities // And then update systems - if (!m_orderedSystemsUpdated) - ReorderSystems(); - for (auto& systemPtr : m_orderedSystems) systemPtr->Update(elapsedTime); } diff --git a/SDK/src/NDK/World.cpp b/SDK/src/NDK/World.cpp index 270bae580..8b041aa5c 100644 --- a/SDK/src/NDK/World.cpp +++ b/SDK/src/NDK/World.cpp @@ -172,6 +172,9 @@ namespace Ndk void World::Update() { + if (!m_orderedSystemsUpdated) + ReorderSystems(); + // Handle killed entities before last call for (std::size_t i = m_killedEntities.FindFirst(); i != m_killedEntities.npos; i = m_killedEntities.FindNext(i)) { @@ -221,12 +224,8 @@ namespace Ndk entity->DestroyComponent(j); removedComponents.Reset(); - for (auto& system : m_systems) + for (auto& system : m_orderedSystems) { - // Ignore non-existent systems - if (!system) - continue; - // Is our entity already part of this system? bool partOfSystem = system->HasEntity(entity);