Skip to main content

diff_cell_frames

Function diff_cell_frames 

Source
pub fn diff_cell_frames(prev: &[Vec<Cell>], next: &[Vec<Cell>]) -> Vec<Patch>
Expand description

Slice-based cell-diff for the retained-mode Screen buffer. Both frames are [Vec<Cell>] indexed by screen row (0..H-1), with each inner Vec<Cell> indexed by screen col (0..W-1). Unlike diff_cells, this variant doesn’t allocate a hashmap per frame — Screen always knows all its rows upfront, so a contiguous slice is both faster and maps 1:1 onto the 2D cells[row][col] access pattern.

Emits patches with 1-indexed (row, col) matching ANSI cursor addressing. When one frame is shorter than the other (shouldn’t happen in practice if both come from the same Screen, but keep the robustness for safety), missing rows / columns are treated as blank so the “other” frame’s content generates explicit patches.