MCPcopy Index your code
hub / github.com/codeaashu/claude-code / migrateScreenPools

Function migrateScreenPools

src/ink/screen.ts:554–587  ·  view source on GitHub ↗
(
  screen: Screen,
  charPool: CharPool,
  hyperlinkPool: HyperlinkPool,
)

Source from the content-addressed store, hash-verified

552 * O(width * height) but only called occasionally (e.g., between conversation turns).
553 */
554export function migrateScreenPools(
555 screen: Screen,
556 charPool: CharPool,
557 hyperlinkPool: HyperlinkPool,
558): void {
559 const oldCharPool = screen.charPool
560 const oldHyperlinkPool = screen.hyperlinkPool
561 if (oldCharPool === charPool && oldHyperlinkPool === hyperlinkPool) return
562
563 const size = screen.width * screen.height
564 const cells = screen.cells
565
566 // Re-intern chars and hyperlinks in a single pass, stride by 2
567 for (let ci = 0; ci < size << 1; ci += 2) {
568 // Re-intern charId (word0)
569 const oldCharId = cells[ci]!
570 cells[ci] = charPool.intern(oldCharPool.get(oldCharId))
571
572 // Re-intern hyperlinkId (packed in word1)
573 const word1 = cells[ci + 1]!
574 const oldHyperlinkId = (word1 >>> HYPERLINK_SHIFT) & HYPERLINK_MASK
575 if (oldHyperlinkId !== 0) {
576 const oldStr = oldHyperlinkPool.get(oldHyperlinkId)
577 const newHyperlinkId = hyperlinkPool.intern(oldStr)
578 // Repack word1 with new hyperlinkId, preserving styleId and width
579 const styleId = word1 >>> STYLE_SHIFT
580 const width = word1 & WIDTH_MASK
581 cells[ci + 1] = packWord1(styleId, newHyperlinkId, width)
582 }
583 }
584
585 screen.charPool = charPool
586 screen.hyperlinkPool = hyperlinkPool
587}
588
589/**
590 * Get a Cell view at the given position. Returns a new object each call -

Callers 1

resetPoolsMethod · 0.85

Calls 3

packWord1Function · 0.85
getMethod · 0.65
internMethod · 0.45

Tested by

no test coverage detected