diff options
| author | Anhgelus Morhtuuzh <william@herges.fr> | 2026-04-28 19:37:37 +0200 |
|---|---|---|
| committer | Anhgelus Morhtuuzh <william@herges.fr> | 2026-04-28 19:37:37 +0200 |
| commit | d9e37656e83d7d3c25709795ab7ccccca0071254 (patch) | |
| tree | 622789be5f608f39d6fdd9b9b99a16209f3b1d7f /src/eval/Title.zig | |
| parent | 3b1e6547d069d7c438af551a4989972802a895ee (diff) | |
perf(eval): reduce memory usage
Diffstat (limited to 'src/eval/Title.zig')
| -rw-r--r-- | src/eval/Title.zig | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/eval/Title.zig b/src/eval/Title.zig index dbb5d38..1841ce7 100644 --- a/src/eval/Title.zig +++ b/src/eval/Title.zig @@ -2,20 +2,36 @@ const std = @import("std"); const Allocator = std.mem.Allocator; const HTML = Parent.HTML; const Parent = @import("Element.zig"); +const Node = Parent.Node; level: u3, content: Parent, +node: Node = .{ + .ptr = undefined, + .vtable = .{ .element = fromNode }, +}, const Self = @This(); pub fn init(alloc: Allocator, level: u3, content: Parent) !*Self { const v = try alloc.create(Self); v.* = .{ .level = level, .content = content }; + v.node.ptr = v; return v; } pub fn element(self: *Self) Parent { - return .{ .ptr = self, .vtable = .{ .html = html } }; + return .{ .ptr = self, .vtable = .{ .html = html, .node = getNode } }; +} + +fn getNode(context: *anyopaque) *Node { + const self: *Self = @ptrCast(@alignCast(context)); + return &self.node; +} + +fn fromNode(context: *anyopaque) Parent { + const self: *Self = @ptrCast(@alignCast(context)); + return self.element(); } fn html(context: *anyopaque, alloc: Allocator) HTML.Error!HTML { |
