MCPcopy Create free account
hub / github.com/Noumena-Network/code / reset

Method reset

src/ink/output.ts:229–246  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

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).

Callers

nothing calls this directly

Calls 3

resetScreenFunction · 0.85
keysMethod · 0.80
deleteMethod · 0.80

Tested by

no test coverage detected