summaryrefslogtreecommitdiff
path: root/core/File.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-21 14:17:28 -0300
committerGabriel Schneider <[email protected]>2026-11-21 14:58:57 -0300
commit8152cf383c8296be29e80175b57e40f8d41049bf (patch)
tree98ab59c0122b73ca6490ab4b778bf0fb7f0582d0 /core/File.zig
parentdfb051bd798f65c2217eea7f95b03dce292e30bf (diff)
downloadpardes-8152cf383c8296be29e80175b57e40f8d41049bf.tar.gz
pardes-8152cf383c8296be29e80175b57e40f8d41049bf.zip
layers: with `Changes` off nothing is paid (P45): the revset and jj's answers are the session's, a list by pane serial (`Pardes.changes`, `jj.answered`; `jj.forget` at the pane's end), no longer a field of every pane, and a view holds only whether it shows them (`File.Layers.lanes`, the cells their lanes take, hashed with `ink` in one update), so a second view's `Changes other` shows the new set in both and its bare `Changes` hides them in its own alone (bare with none pinned yet is `@`); measured first, per operation against gpu/tree3 (a gui ReleaseFast pardes-perf, perfops's way of counting: reorg/pardes-layers-4/perf): merge50 +0.005% a client key, round 3 +0.110%, a packed one-byte `Layers` +0.391% (a packed field cost the walks more), a plain two-byte one +0.152%, the per-pane field gone +0.118%, the gutter's three reads of the lanes taken out +0.066% with body-appends from +0.189% to -0.004%: what paid was fillBody's line number, formatted for every row of every geometry pass (no `dst`, a hundred a frame) and thrown away, whose row loop moved with any value added to it: it is now written only into a `dst` (client key +0.017%, deep-sel +0.002%, render -0.021%, body-appends -1.555%); and `jj.of` (round 1's) gave a revision's name as a slice of a by-value copy of the pane's Output, dangling once it returned (jj told "Non-UTF-8 argument" for `Changes` in a revision's pane in a window build): the pane's own now; tests: the pinned changes are the pane's, shown in a view by its own bit (a second view's revset shows in both, its bare Changes hides them there alone), the two of a terminal's cells said so (`.windowed = false`); core-test 896/1056 (160 skipped), shell-test 1098/1101 (3 skipped), gui unit-test 1695/1699 (4 skipped); the frame and perf gate against tree3 (gpu/l4-g0): 77/77 frames, 0 differ, perfab corpus2x +0.005% (noise 0.058%), perfops 121 counts within 0.1% (largest terminal on all +0.082%)
Co-Authored-By: Claude Opus <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'core/File.zig')
-rw-r--r--core/File.zig75
1 files changed, 34 insertions, 41 deletions
diff --git a/core/File.zig b/core/File.zig
index f7d6bced..6e44f85e 100644
--- a/core/File.zig
+++ b/core/File.zig
@@ -1777,6 +1777,8 @@ fn geometryKey(pane: *const Pane, f: *const State) u64 {
fn fillBody(tab: u16, dst: ?[]u8, pane: *Pane, f: *State, width: usize, record_wrap: bool) usize {
if (record_wrap) pane.wrap_n = 0;
const prefix_width = gutterWidth(pane);
+ // Where a number ends: a blank, then the lanes (laneCells), after it.
+ const number_end = prefix_width -| laneCells(pane) -| 1;
const total = nlines(pane.gpa, f);
// The slot after the text's last newline, found once: every numbered
// row below asks whether it is that one.
@@ -1814,24 +1816,25 @@ fn fillBody(tab: u16, dst: ?[]u8, pane: *Pane, f: *State, width: usize, record_w
pane.wrap_n = @intCast(i + 1);
}
if (row < total) {
- var lbuf: [@max(config.PREFIX_W, 32)]u8 = undefined;
- const prefix = lbuf[0..prefix_width];
- @memset(prefix, ' ');
- if (at == 0 and prefix.len > 0) {
- var lineno = row + 1;
- // The number, a blank, then the lanes (laneCells).
- var digit: usize = prefix.len - 1 - laneCells(pane);
- if (row == end_slot) {
- prefix[digit - 1] = '~';
- } else while (true) {
- digit -= 1;
- prefix[digit] = '0' + @as(u8, @intCast(lineno % 10));
- lineno /= 10;
- if (lineno == 0) break;
+ // The number only where the text is wanted: a geometry pass (no
+ // `dst`, a hundred a frame) counts its cells and nothing more.
+ if (dst) |out| {
+ const prefix = out[written..][0..prefix_width];
+ @memset(prefix, ' ');
+ if (at == 0 and prefix.len > 0) {
+ var lineno = row + 1;
+ var digit: usize = number_end;
+ if (row == end_slot) {
+ prefix[digit - 1] = '~';
+ } else while (true) {
+ digit -= 1;
+ prefix[digit] = '0' + @as(u8, @intCast(lineno % 10));
+ lineno /= 10;
+ if (lineno == 0) break;
+ }
}
}
- if (dst) |out| @memcpy(out[written..][0..prefix.len], prefix);
- written += prefix.len;
+ written += prefix_width;
if (dst) |out| @memcpy(out[written..][0..guide.len], guide);
written += guide.len;
// A table row's pads are blanks before their bytes: the row
@@ -1877,38 +1880,28 @@ fn fillBody(tab: u16, dst: ?[]u8, pane: *Pane, f: *State, width: usize, record_w
/// Both are painted in recolorSyntax's one walk over the cells, each where
/// it says (one walk per painter cost a frame a sixth more).
///
-/// 3. changes (`Changes [revset]`, jj.zig): while `revset` is set, a
-/// lane a pinned change after the line number (the gutter `lanes`
-/// cells wider), a line one added whole green across it (jj.paint).
-/// Ruled, not built (PARDES.md "Changes on the source view"): a
-/// changed line's words tinted, ghost rows for what the shown
-/// revision has not.
+/// 3. changes (`Changes [revset]`, jj.zig): while `lanes` is set, a
+/// lane each of the pane's pinned changes after the line number (the
+/// gutter `lanes` cells wider), a line one added whole green across
+/// it (jj.paint). Ruled, not built (PARDES.md "Changes on the source
+/// view"): a changed line's words tinted, ghost rows for what the
+/// shown revision has not.
/// 4. churn, ruled, not built: a heat lane after the number and a strip
/// by the scroll thumb.
+///
+/// Two bytes, hashed in one update: a digest takes every view's of every
+/// pane at every step.
pub const Layers = struct {
- pub const replica = .{ .len = .{.{ "revset", "revset_len" }} };
ink: bool = true,
- /// The changes this view pins (jj's revset), none while empty; what jj
- /// answered for them is the pane's (`Pane.changes`).
- revset: [revset_max]u8 = undefined,
- revset_len: u8 = 0,
- /// The cells its lanes take while it pins any, 0 while it pins none
- /// (laneCells): set as it pins them, from the view's frontend: in a
- /// window two, which its strips of pixels fill one and a half of
- /// (Surface.Lane); in a terminal three, a glyph each.
+ /// Whether this view shows the pane's pinned changes (`Pardes.changes`:
+ /// the revset and jj's answers are the pane's), as the cells their
+ /// lanes take (laneCells), 0 while it does not: set from the view's
+ /// frontend, in a window two, which its strips of pixels fill one and
+ /// a half of (Surface.Lane), in a terminal three, a glyph each.
lanes: u8 = 0,
- pub const revset_max = 64;
-
- pub fn pinned(l: *const Layers) []const u8 {
- return l.revset[0..l.revset_len];
- }
-
- /// One word while it pins nothing: a digest walks every view's layers
- /// of every pane (field by field it cost a step 0.1 to 0.7% more).
pub fn digest(l: *const Layers, h: *pardes.walk.Hasher) void {
- h.update(&.{ @intFromBool(l.ink), l.revset_len, l.lanes });
- if (l.revset_len > 0) h.update(l.pinned());
+ h.update(&.{ @intFromBool(l.ink), l.lanes });
}
};