From bb3d189676a9681542a61b453f0eb55208cc1311 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 17 Nov 2026 04:16:23 -0300 Subject: terminal: the function keys' table written out: `comptime` built it with std.fmt.comptimePrint("f{d}") a key, 25 calls of an inline function, never memoized, in every compile of the terminal (about 0.1e9 of the compiler's instructions, by the walker's measure of comptimePrint); it is the 25 tags in one line, the same table; nothing else changes --- src/term/terminal.zig | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'src') diff --git a/src/term/terminal.zig b/src/term/terminal.zig index fff491f6..71a2f3de 100644 --- a/src/term/terminal.zig +++ b/src/term/terminal.zig @@ -939,11 +939,7 @@ pub fn commandOutput(state: ?*State, gpa: std.mem.Allocator, max_rows: usize) !T /// ask for it, written to `out`. pub fn key(state: *State, k: Key, out: *std.Io.Writer) !void { const input = ghostty_vt.input; - const function_keys = comptime keys: { - var keys: [Key.f25 - Key.f1 + 1]input.Key = undefined; - for (&keys, 1..) |*slot, n| slot.* = @field(input.Key, std.fmt.comptimePrint("f{d}", .{n})); - break :keys keys; - }; + const function_keys = [Key.f25 - Key.f1 + 1]input.Key{ .f1, .f2, .f3, .f4, .f5, .f6, .f7, .f8, .f9, .f10, .f11, .f12, .f13, .f14, .f15, .f16, .f17, .f18, .f19, .f20, .f21, .f22, .f23, .f24, .f25 }; const physical: input.Key = switch (k.cp) { Key.enter => .enter, Key.backspace => .backspace, -- cgit v1.3