chore(tui): /clean recent perf work — KISS/DRY pass

24 files, -319 LoC. Behaviour preserved, 369/369 tests green.

- hermes-ink caches: shared lruEvict helper for the four parallel LRU
  caches (stringWidth, wrapText, sliceAnsi, lineWidth); touch-on-read
  stays inlined per cache; tightened output.ts skip-slice fast path.
- wheelAccel: trimmed provenance header, collapsed env parsing, ternary
  dispatch in computeWheelStep.
- perfPane: folded ensureLogDir into once-flag, spread-with-overrides
  for fastPath/phases instead of full rebuilds.
- env: extracted truthy() (used 4×).
- virtualHeights: collapsed user/diff/slash height bumps; trail+todos
  estimate.
- useInputHandlers: scrollIdleTimer cleanup on unmount, ?? undefined
  shorthand.
- useMainApp: dropped dead liveTailVisible IIFE and liveProgress
  indirection.
- appLayout, markdown, messageLine, entry: vertical rhythm, dropped
  narration comments, inlined one-shot vars.
- fix: empty catch blocks → /* best-effort */ for no-empty lint.
This commit is contained in:
Brooklyn Nicholson 2026-04-26 20:38:47 -05:00
parent 527ac351b4
commit b1c49d5e73
32 changed files with 259 additions and 547 deletions

View file

@ -4,6 +4,8 @@ import stripAnsi from 'strip-ansi'
import { getGraphemeSegmenter } from '../utils/intl.js'
import { lruEvict } from './lru.js'
const EMOJI_REGEX = emojiRegex()
/**
@ -299,6 +301,7 @@ export const stringWidth: (str: string) => number = str => {
if (code >= 127 || code === 0x1b) {
asciiOnly = false
break
}
}
@ -334,14 +337,5 @@ export function widthCacheSize(): number {
}
export function evictWidthCache(keepRatio = 0): void {
if (keepRatio <= 0) {
widthCache.clear()
return
}
const target = Math.floor(widthCache.size * keepRatio)
while (widthCache.size > target) {
widthCache.delete(widthCache.keys().next().value!)
}
lruEvict(widthCache, keepRatio)
}