writeBytes(" ") in the render loopSeverity: LOW (performance)
Status: ✅ FIXED
Files: src/server/render.zig:597-599, src/server/render.zig:709
if (cp == 0 or cp == ' ') {
try self.writeBytes(" ");
cur_cx += 1;
}
(render.zig:597-599) Each blank/sixel-anchor cell is one separate writeBytes(" ") append. Same pattern at render.zig:709 for status-bar padding. In the interactive loop writeBytes appends to the capture frame buffer, so 80 consecutive spaces per row is 80 small append calls where one appendSlice of a pre-sized 80-space string would do. On mostly-blank screens (the common case — prompts, sparse TUIs) blank cells are the dominant cell type, so this is the most frequent inner-loop append.
Accumulate a run-length of consecutive spaces and emit one writeBytes(spaces[0..run]) (a static space buffer sized to sx) instead of N one-byte appends. Same for the status-bar padding loop at line 709.
renderContent (src/server/render.zig) batches a run of consecutive
identical blank cells into one writeBytes(spaces[0..run]) using a 256-byte
space scratch; runs are capped at the scratch size so wider rows spill into
the next batch, padding cells stop a run, and cells whose last-known state was
a sixel are excluded so the per-cell \x1b[X erase behaviour is unchanged.
The status-bar padding loop now emits the remaining columns as space-run
chunks of the same scratch buffer instead of one write per column.
Tests: a batched blank row is emitted as a single space run, and
renderStatusBar pads a short line to the full width with the expected run.
Verified: zig build test -Doptimize=ReleaseFast — 1012/1012 tests pass.