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

Function diffSameWidth

src/ink/screen.ts:1673–1740  ·  view source on GitHub ↗

* Diff two screens with identical width. * Dispatches each row to a small, JIT-friendly function.

(
  prev: Screen,
  next: Screen,
  startX: number,
  endX: number,
  startY: number,
  endY: number,
  cb: DiffCallback,
)

Source from the content-addressed store, hash-verified

1671 * Dispatches each row to a small, JIT-friendly function.
1672 */
1673function diffSameWidth(
1674 prev: Screen,
1675 next: Screen,
1676 startX: number,
1677 endX: number,
1678 startY: number,
1679 endY: number,
1680 cb: DiffCallback,
1681): boolean {
1682 const prevCells = prev.cells
1683 const nextCells = next.cells
1684 const width = prev.width
1685 const prevHeight = prev.height
1686 const nextHeight = next.height
1687 const stride = width << 1
1688
1689 const prevCell: Cell = {
1690 char: ' ',
1691 styleId: 0,
1692 width: CellWidth.Narrow,
1693 hyperlink: undefined,
1694 }
1695 const nextCell: Cell = {
1696 char: ' ',
1697 styleId: 0,
1698 width: CellWidth.Narrow,
1699 hyperlink: undefined,
1700 }
1701
1702 const rowEndX = Math.min(endX, width)
1703 let rowCI = (startY * width + startX) << 1
1704
1705 for (let y = startY; y < endY; y++) {
1706 const prevIn = y < prevHeight
1707 const nextIn = y < nextHeight
1708
1709 if (prevIn && nextIn) {
1710 if (
1711 diffRowBoth(
1712 prevCells,
1713 nextCells,
1714 prev,
1715 next,
1716 rowCI,
1717 y,
1718 startX,
1719 rowEndX,
1720 prevCell,
1721 nextCell,
1722 cb,
1723 )
1724 )
1725 return true
1726 } else if (prevIn) {
1727 if (diffRowRemoved(prev, rowCI, y, startX, rowEndX, prevCell, cb))
1728 return true
1729 } else if (nextIn) {
1730 if (

Callers 1

diffEachFunction · 0.85

Calls 3

diffRowBothFunction · 0.85
diffRowRemovedFunction · 0.85
diffRowAddedFunction · 0.85

Tested by

no test coverage detected