From 2536110e142a3cb548a43235767ac7ae6efa357c Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 17 Nov 2026 02:43:58 -0300 Subject: walk: the tape's shape appends each piece whole: `out = out ++ name ++ ":" ++ shapeOf(F) ++ ","` is ((out ++ name) ++ ":") ++ ..., so the shape so far (up to 11 KB, every union arm and struct field of the tape's types) was copied at comptime once a piece, four times a field, and a comptime copy is costly (32 KB built of 4,000 appends: 226e9 of the compiler's instructions); the piece is put together first and appended once, in shape (each type's line), an enum's values, a struct's and a union's fields; the shape is the same 10,960 bytes and wire.semantics the same 05b2cba8834b1d7c; core-test's forced full recompile (Debug, one filter) 103.41e9 to 101.37e9 instructions (-1.7 % of the base's 120.12e9; all five changes together -15.6 %, 15.5-16.1 s of CPU to 13.6-14.4 s, and 9.0-9.2 s wall against 10.2-11.0 s, both noisy), the Debug test's text unchanged; a session's byte dump, its image and a closed pane's save the same bytes (but the clock's) and each build loads the other's; the changelog says so --- src/walk.zig | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/walk.zig') diff --git a/src/walk.zig b/src/walk.zig index 8747937d..0f181cfa 100644 --- a/src/walk.zig +++ b/src/walk.zig @@ -367,7 +367,7 @@ pub fn shape(comptime types: []const type) []const u8 { comptime { @setEvalBranchQuota(10_000_000); var out: []const u8 = ""; - for (types) |T| out = out ++ shapeOf(T, 0) ++ "\n"; + for (types) |T| out = out ++ (shapeOf(T, 0) ++ "\n"); return out; } } @@ -382,7 +382,7 @@ fn shapeOf(comptime T: type, comptime depth: u8) []const u8 { .float => |f| "f" ++ decimal(f.bits), .@"enum" => |e| blk: { var out: []const u8 = shapeOf(e.tag_type, depth + 1) ++ "{"; - for (e.field_names, e.field_values) |n, v| out = out ++ n ++ "=" ++ decimal(v) ++ ","; + for (e.field_names, e.field_values) |n, v| out = out ++ (n ++ "=" ++ decimal(v) ++ ","); break :blk out ++ "}"; }, .optional => |o| if (machinery(o.child)) "0" else "?" ++ shapeOf(o.child, depth + 1), @@ -397,13 +397,13 @@ fn shapeOf(comptime T: type, comptime depth: u8) []const u8 { var out: []const u8 = if (s.layout == .@"packed") "p{" else "{"; for (s.field_names, s.field_types, s.field_attrs) |name, F, attr| { if (attr.@"comptime" or excluded(T, name)) continue; - out = out ++ name ++ ":" ++ shapeOf(F, depth + 1) ++ ","; + out = out ++ (name ++ ":" ++ shapeOf(F, depth + 1) ++ ","); } break :blk out ++ "}"; }, .@"union" => |u| blk: { var out: []const u8 = shapeOf(u.tag_type.?, depth + 1) ++ "("; - for (u.field_names, u.field_types) |name, F| out = out ++ name ++ ":" ++ shapeOf(F, depth + 1) ++ ","; + for (u.field_names, u.field_types) |name, F| out = out ++ (name ++ ":" ++ shapeOf(F, depth + 1) ++ ","); break :blk out ++ ")"; }, .error_set => "error", -- cgit v1.3