* Reuse this Output for a new frame. Zeroes the screen buffer, clears * the operation list (backing storage is retained), and caps charCache * growth. Preserving charCache across frames is the main win — most * lines don't change between renders, so tokenize + grapheme clustering * becom
(width: number, height: number, screen: Screen)
| 227 | * becomes a cache hit. |
| 228 | */ |
| 229 | reset(width: number, height: number, screen: Screen): void { |
| 230 | this.width = width |
| 231 | this.height = height |
| 232 | this.screen = screen |
| 233 | this.operations.length = 0 |
| 234 | resetScreen(screen, width, height) |
| 235 | if (this.charCache.size > 16384) { |
| 236 | // Evict oldest 25% instead of full clear. charCache is shared across |
| 237 | // Output instances; a full clear forces expensive re-tokenization, |
| 238 | // grapheme clustering, and bidi reordering of every visible line. |
| 239 | const evictCount = Math.floor(this.charCache.size * 0.25) |
| 240 | let evicted = 0 |
| 241 | for (const key of this.charCache.keys()) { |
| 242 | this.charCache.delete(key) |
| 243 | if (++evicted >= evictCount) break |
| 244 | } |
| 245 | } |
| 246 | } |
| 247 | |
| 248 | /** |
| 249 | * Copy cells from a source screen region (blit = block image transfer). |
nothing calls this directly
no test coverage detected