From 263a149713fcc18a6df860bf212677ccdb0eb982 Mon Sep 17 00:00:00 2001 From: Ryan Liptak Date: Mon, 29 Jul 2024 21:43:08 -0700 Subject: [PATCH] Make Node in named_character_references a packed struct MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Node being a `struct` instead of a `packed struct(u22)` was a mistake left over from me testing different struct layouts. Switching back to the intended `packed struct(u22)` give a free speedup and a binary size decrease (minus 7KiB): Benchmark 1 (637 runs): bench-autostruct.exe measurement mean ± σ min … max outliers delta wall_time 7.85ms ± 203us 7.56ms … 11.2ms 18 ( 3%) 0% peak_rss 2.89MB ± 8.99KB 2.89MB … 3.12MB 39 ( 6%) 0% Benchmark 2 (720 runs): bench-packedstructu22.exe measurement mean ± σ min … max outliers delta wall_time 6.94ms ± 177us 6.71ms … 8.80ms 36 ( 5%) ⚡- 11.6% ± 0.3% peak_rss 2.88MB ± 8.46KB 2.88MB … 3.11MB 45 ( 6%) - 0.3% ± 0.0% --- src/html/named_character_references.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/html/named_character_references.zig b/src/html/named_character_references.zig index 9898caa..37be167 100644 --- a/src/html/named_character_references.zig +++ b/src/html/named_character_references.zig @@ -62,7 +62,7 @@ fn findInList(first_child_index: u12, char: u8) ?u12 { unreachable; } -pub const Node = struct { +pub const Node = packed struct(u22) { char: u8, /// If true, this node is the end of a valid named character reference. /// Note: This does not necessarily mean that this node does not have child nodes.