Evict the oldest entries when the cache exceeds MAX_CACHE_ENTRIES. * Map iteration order is insertion order, so the first keys are the oldest.
()
| 18 | /** Evict the oldest entries when the cache exceeds MAX_CACHE_ENTRIES. |
| 19 | * Map iteration order is insertion order, so the first keys are the oldest. */ |
| 20 | function enforceCacheLimit() { |
| 21 | while (SHARED_HIGHLIGHTED_DIFF_CACHE.size > MAX_CACHE_ENTRIES) { |
| 22 | const oldest = SHARED_HIGHLIGHTED_DIFF_CACHE.keys().next().value; |
| 23 | if (oldest !== undefined) { |
| 24 | SHARED_HIGHLIGHTED_DIFF_CACHE.delete(oldest); |
| 25 | } |
| 26 | } |
| 27 | } |
| 28 | |
| 29 | /** Summarize rendered diff lines without serializing whole arrays into the cache key. */ |
| 30 | function lineSetFingerprint(lines: string[] | undefined) { |
no outgoing calls
no test coverage detected