#pragma once #include #include #include 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 void trimHistoryPreviews(std::map &cache, const std::set &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; } }