Files
opentui/packages/native
Simon Klee ca25b66882 native: resize buffers in place while the cells fit (#1537)
OptimizedBuffer.resize reallocated all four cell arrays on every size
change. When a reallocation moved, it copied cells that clear() then
overwrote. If one reallocation failed, the arrays were left with
different lengths while width and height kept the old size, so a failed
shrink left a cell array shorter than the buffer's cells.

Resize now reuses the arrays while the new cells fit and the capacity
stays within half again the cells. Growing past the capacity reserves
half
of it again, so a buffer that grows a row at a time or alternates sizes
reallocates rarely. A larger jump or a shrink takes the exact cells. All
four arrays are allocated before any is freed, so a failed resize leaves
the buffer unchanged.
2026-09-27 15:31:30 +02:00
..
2026-09-22 10:11:24 +02:00