18 lines
549 B
C++
18 lines
549 B
C++
#pragma once
|
|
#include <map>
|
|
#include <set>
|
|
#include <string>
|
|
|
|
namespace ks {
|
|
// Keep the visible working set even in unusually tall windows. Never evict a
|
|
// visible preview to admit another visible preview: that creates a paint loop.
|
|
template<class T>
|
|
void trimHistoryPreviews(std::map<std::wstring,T> &cache,
|
|
const std::set<std::wstring> &visible, size_t limit=32)
|
|
{
|
|
for(auto it=cache.begin(); cache.size()>limit && it!=cache.end();)
|
|
if(!visible.contains(it->first)) it=cache.erase(it);
|
|
else ++it;
|
|
}
|
|
}
|