FullscreenUI: Various improvements

This commit is contained in:
Connor McLaughlin
2022-09-17 15:51:05 +10:00
parent 91c8681bed
commit ef3ad91ad0
34 changed files with 1350 additions and 514 deletions

View File

@ -69,7 +69,7 @@ public:
void Evict(std::size_t count = 1)
{
while (m_items.size() >= count)
while (!m_items.empty() && count > 0)
{
typename MapType::iterator lowest = m_items.end();
for (auto iter = m_items.begin(); iter != m_items.end(); ++iter)
@ -78,6 +78,7 @@ public:
lowest = iter;
}
m_items.erase(lowest);
count--;
}
}
@ -87,23 +88,20 @@ public:
auto iter = m_items.find(key);
if (iter == m_items.end())
return false;
m_items.erase(iter);
return true;
}
void SetManualEvict(bool block)
{
m_manual_evict = block;
if (!m_manual_evict)
ManualEvict();
}
void ManualEvict()
{
// evict if we went over
while (m_items.size() > m_max_capacity)
Evict(m_items.size() - (m_max_capacity - 1));
Evict(m_items.size() - m_max_capacity);
}
private: