Skip to content

Commit

Permalink
Tweaked: Check the archetype set first during archetype deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
richardbiely committed Sep 30, 2024
1 parent 47569a0 commit 2d79133
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
9 changes: 6 additions & 3 deletions include/gaia/ecs/query_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -354,11 +354,14 @@ namespace gaia {
}

bool del_archetype_from_cache(Archetype* pArchetype) {
const auto idx = core::get_index(m_archetypeCache, pArchetype);
if (idx == BadIndex)
const auto it = m_archetypeSet.find(pArchetype);
if (it == m_archetypeSet.end())
return false;
m_archetypeSet.erase(it);

const auto idx = core::get_index_unsafe(m_archetypeCache, pArchetype);
GAIA_ASSERT(idx != BadIndex);

m_archetypeSet.erase(pArchetype);
core::erase_fast(m_archetypeCache, idx);
core::erase_fast(m_archetypeCacheData, idx);

Expand Down
9 changes: 6 additions & 3 deletions single_include/gaia.h
Original file line number Diff line number Diff line change
Expand Up @@ -23254,11 +23254,14 @@ namespace gaia {
}

bool del_archetype_from_cache(Archetype* pArchetype) {
const auto idx = core::get_index(m_archetypeCache, pArchetype);
if (idx == BadIndex)
const auto it = m_archetypeSet.find(pArchetype);
if (it == m_archetypeSet.end())
return false;
m_archetypeSet.erase(it);

const auto idx = core::get_index_unsafe(m_archetypeCache, pArchetype);
GAIA_ASSERT(idx != BadIndex);

m_archetypeSet.erase(pArchetype);
core::erase_fast(m_archetypeCache, idx);
core::erase_fast(m_archetypeCacheData, idx);

Expand Down

0 comments on commit 2d79133

Please sign in to comment.