pub struct BufferDiff { /* private fields */ }Expand description
The diff between two buffers.
Contains the list of (x, y) positions where cells differ.
Implementations§
Source§impl BufferDiff
impl BufferDiff
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Create a diff with pre-allocated capacity.
Sourcepub fn full(width: u16, height: u16) -> Self
pub fn full(width: u16, height: u16) -> Self
Create a diff that marks every cell as changed.
Useful for full-screen redraws where the previous buffer is unknown (e.g., after resize or initial present).
Sourcepub fn compute(old: &Buffer, new: &Buffer) -> Self
pub fn compute(old: &Buffer, new: &Buffer) -> Self
Compute the diff between two buffers.
Uses row-major scan for cache efficiency. Both buffers must have the same dimensions.
§Optimizations
- Row-skip fast path: unchanged rows are detected via slice equality and skipped entirely. For typical UI updates where most rows are static, this eliminates the majority of per-cell work.
- Blockwise row scan: rows with sparse edits are scanned in coarse blocks, skipping unchanged blocks and only diving into the blocks that differ.
- Direct slice iteration: row slices are computed once per row
instead of calling
get_unchecked(x, y)per cell, eliminating repeatedy * width + xindex arithmetic. - Branchless cell comparison:
bits_equses bitwise AND to avoid branch mispredictions in the inner loop.
§Panics
Debug-asserts that both buffers have identical dimensions.
Sourcepub fn compute_into(&mut self, old: &Buffer, new: &Buffer)
pub fn compute_into(&mut self, old: &Buffer, new: &Buffer)
Compute the diff into an existing buffer to reuse allocation.
Sourcepub fn compute_dirty(old: &Buffer, new: &Buffer) -> Self
pub fn compute_dirty(old: &Buffer, new: &Buffer) -> Self
Compute the diff between two buffers using dirty-row hints.
Only rows marked dirty in new are compared cell-by-cell.
Clean rows are skipped entirely (O(1) per clean row).
This is sound provided the dirty tracking invariant holds:
for all y, if any cell in row y changed, then new.is_row_dirty(y).
Falls back to full comparison for rows marked dirty, so false positives (marking a row dirty when it didn’t actually change) are safe — they only cost the per-cell scan for that row.
Sourcepub fn compute_dirty_into(&mut self, old: &Buffer, new: &Buffer)
pub fn compute_dirty_into(&mut self, old: &Buffer, new: &Buffer)
Compute the dirty-row diff into an existing buffer to reuse allocation.
Sourcepub fn last_tile_stats(&self) -> Option<TileDiffStats>
pub fn last_tile_stats(&self) -> Option<TileDiffStats>
Access the last tile diagnostics from a dirty diff pass.
Sourcepub fn tile_config_mut(&mut self) -> &mut TileDiffConfig
pub fn tile_config_mut(&mut self) -> &mut TileDiffConfig
Mutably access tile diff configuration.
Trait Implementations§
Source§impl Clone for BufferDiff
impl Clone for BufferDiff
Source§fn clone(&self) -> BufferDiff
fn clone(&self) -> BufferDiff
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more