From 3b1e6547d069d7c438af551a4989972802a895ee Mon Sep 17 00:00:00 2001 From: Anhgelus Morhtuuzh Date: Tue, 28 Apr 2026 15:08:02 +0200 Subject: perf(html): reduce memory usage --- src/eval/list.zig | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/eval/list.zig') diff --git a/src/eval/list.zig b/src/eval/list.zig index 06b7af7..2ba136a 100644 --- a/src/eval/list.zig +++ b/src/eval/list.zig @@ -21,13 +21,15 @@ fn List(comptime tag: []const u8) type { return .{ .ptr = self, .vtable = .{ .html = html } }; } - fn html(context: *anyopaque, alloc: Allocator) HTML.Error!HTML { + fn html(context: *anyopaque, alloc: Allocator) HTML.Error!HTML { const self: *Self = @ptrCast(@alignCast(context)); var el = try HTML.Content.init(alloc, tag); + var root = try HTML.Root.init(alloc); + el.content = root.element(); for (self.content.items) |it| { - var li = try HTML.Content.init(alloc, "li"); - try li.append(try it.html(alloc)); - try el.append(li.element()); + var li = try HTML.Content.init(root.allocator(), "li"); + li.content = try it.html(root.allocator()); + root.append(li.element()); } return el.element(); } -- cgit v1.2.3