summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-10-30 03:48:41 -0300
committerGabriel Schneider <[email protected]>2026-10-30 04:08:29 -0300
commit5cea19dfded7027090234bbe41fdaac3d379e012 (patch)
tree4aaca977337f872b53539fa2e5fd29fb41e52367 /src
parent1f5ef5bc77f12b721864c2785d9daedc82947e57 (diff)
downloadpardes-5cea19dfded7027090234bbe41fdaac3d379e012.tar.gz
pardes-5cea19dfded7027090234bbe41fdaac3d379e012.zip
terminal: a shell's cells painted from the row's own pin (cellAt), not getCell's walk from the viewport's top to the row for every cell: a frame of a 120x40 terminal over 64 KB to 8 MB of scrollback 107-127 -> 94-102 us against base, ReleaseFast; the 'regression' phase 5B read against base was a Debug-core perf binary (core_optimize debug, terminal safe) beside a ReleaseFast one, file gestures level once both are ReleaseFast
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/terminal.zig18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/terminal.zig b/src/terminal.zig
index 42268f0a..acff68f4 100644
--- a/src/terminal.zig
+++ b/src/terminal.zig
@@ -2313,7 +2313,7 @@ pub fn recolorAnsi(p: *Pardes, s: *Surface, pane: *Pane, r: pardes.Rect, tx: u16
crossed = true;
const upto = anchor.shell_len - @min(anchor.suffix, anchor.shell_len);
while (sb < upto) {
- const ci = pages.getCell(.{ .viewport = .{ .x = gc, .y = @intCast(vi) } }) orelse break;
+ const ci = cellAt(pages, row_pin, gc) orelse break;
sb += dumpedBytes(row_pin, ci.cell);
gc = std.math.add(u16, gc, 1) catch break;
}
@@ -2324,7 +2324,7 @@ pub fn recolorAnsi(p: *Pardes, s: *Surface, pane: *Pane, r: pardes.Rect, tx: u16
var covered: usize = 0;
var style: ?pardes.CellStyle = null;
while (covered < want) {
- const ci = pages.getCell(.{ .viewport = .{ .x = gc, .y = @intCast(vi) } }) orelse break;
+ const ci = cellAt(pages, row_pin, gc) orelse break;
if (style == null and ci.cell.wide != .spacer_tail and ci.cell.wide != .spacer_head)
style = cellStyle(p, ci, filtered, scnm);
covered += dumpedBytes(row_pin, ci.cell);
@@ -2333,7 +2333,7 @@ pub fn recolorAnsi(p: *Pardes, s: *Surface, pane: *Pane, r: pardes.Rect, tx: u16
// spin on a row that ends in one.
if (covered == 0 and gc >= pane.cols) break;
}
- while (pages.getCell(.{ .viewport = .{ .x = gc, .y = @intCast(vi) } })) |t| {
+ while (cellAt(pages, row_pin, gc)) |t| {
if (t.cell.wide != .spacer_tail) break;
gc = std.math.add(u16, gc, 1) catch break;
}
@@ -2350,7 +2350,7 @@ pub fn recolorAnsi(p: *Pardes, s: *Surface, pane: *Pane, r: pardes.Rect, tx: u16
var tail: ?pardes.CellStyle = null;
if (anchor.whole() or anchor.suffix > 0) {
while (sc < tw) {
- const ci = pages.getCell(.{ .viewport = .{ .x = gc, .y = @intCast(vi) } }) orelse break;
+ const ci = cellAt(pages, row_pin, gc) orelse break;
gc = std.math.add(u16, gc, 1) catch break;
if (ci.cell.wide == .spacer_tail) continue;
const cell = s.at(tx + sc, body_y + vr);
@@ -2371,6 +2371,16 @@ pub fn recolorAnsi(p: *Pardes, s: *Surface, pane: *Pane, r: pardes.Rect, tx: u16
}
}
+/// The cell at column `x` of the row `row` pins, as `pages.getCell` reads
+/// it, without walking from the viewport's top down to the row again: that
+/// walk, once a cell, was most of a terminal's paint (once getCell was no
+/// longer inlined, a frame of a 120x40 shell took 75 µs more).
+fn cellAt(pages: *const ghostty_vt.PageList, row: ghostty_vt.Pin, x: u16) ?ghostty_vt.PageList.Cell {
+ if (x >= pages.cols or x >= row.node.cols()) return null;
+ const rac = row.node.page().getRowAndCell(x, row.y);
+ return .{ .node = row.node, .row = rac.row, .cell = rac.cell, .row_idx = row.y, .col_idx = x };
+}
+
fn cellStyle(p: *Pardes, ci: ghostty_vt.PageList.Cell, filtered: ?*FilteredColors, scnm: bool) pardes.CellStyle {
const style = ci.style();
var cs: pardes.CellStyle = .{