pub struct BoundedLruCache<K, V> { /* private fields */ }Expand description
Small bounded LRU cache used by renderer hot-path caches.
Hits update recency in place, so the common path is a single hash lookup. Eviction unlinks the oldest entry, which costs the same whether the cache holds ten entries or ten thousand.
The recency order is a linked list rather than a timestamp per entry because a timestamp makes eviction a scan for the minimum. These caches are large – thousands of glyph masks – and the workloads that need them most are the ones that miss steadily: text whose size animates re-rasterises every glyph of every frame, and every one of those inserts was walking the whole table to decide what to drop.
A key is held twice, once in the index and once in its slot, so an eviction
can find the index entry to remove without searching for it. The keys these
caches use are small Copy structs, and the duplicate is what keeps the
links free of raw pointers.