FullscreenUI: Various improvements
This commit is contained in:
@ -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:
|
||||
|
||||
Reference in New Issue
Block a user