Evicts stale entries from the text measurement cache. Entries that haven't been used for more than 2 generations are removed.
(&mut self)
| 2278 | /// Evicts stale entries from the text measurement cache. |
| 2279 | /// Entries that haven't been used for more than 2 generations are removed. |
| 2280 | fn evict_stale_text_cache(&mut self) { |
| 2281 | let gen = self.generation; |
| 2282 | let measured_words = &mut self.measured_words; |
| 2283 | let free_list = &mut self.measured_words_free_list; |
| 2284 | self.measure_text_cache.retain(|_, item| { |
| 2285 | if gen.wrapping_sub(item.generation) <= 2 { |
| 2286 | true |
| 2287 | } else { |
| 2288 | // Clean up measured words for this evicted entry |
| 2289 | let mut idx = item.measured_words_start_index; |
| 2290 | while idx != -1 { |
| 2291 | let word = measured_words[idx as usize]; |
| 2292 | free_list.push(idx); |
| 2293 | idx = word.next; |
| 2294 | } |
| 2295 | false |
| 2296 | } |
| 2297 | }); |
| 2298 | } |
| 2299 | |
| 2300 | fn initialize_ephemeral_memory(&mut self) { |
| 2301 | self.layout_element_children_buffer.clear(); |