Erase m_CurrentResources from the end not the beginning

* Since it's a sorted vector this avoids O(n^2) time to erase everything one by
  one.
This commit is contained in:
baldurk
2020-09-04 12:06:09 +01:00
parent 9b37a8b8a7
commit 9fc97f6097
+9 -3
View File
@@ -89,13 +89,19 @@ public:
while(!m_CurrentResources.empty())
{
auto it = m_CurrentResources.begin();
auto it = m_CurrentResources.end();
--it;
ResourceId id = it->second.first;
if(it->second.second)
it->second.second->Delete(this);
if(!m_CurrentResources.empty() && m_CurrentResources.begin()->second.first == id)
m_CurrentResources.erase(m_CurrentResources.begin());
if(!m_CurrentResources.empty())
{
auto last = m_CurrentResources.end();
last--;
if(last->second.first == id)
m_CurrentResources.erase(last);
}
}
m_CurrentResources.clear();