From e7fa254387e450154f03b2d1bdef361a0adb80d1 Mon Sep 17 00:00:00 2001 From: Anhgelus Morhtuuzh Date: Fri, 24 Apr 2026 17:40:33 +0200 Subject: perf(lexer): do not alloc --- src/paragraph.zig | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/paragraph.zig') diff --git a/src/paragraph.zig b/src/paragraph.zig index 0382e5d..c8c6798 100644 --- a/src/paragraph.zig +++ b/src/paragraph.zig @@ -1,6 +1,6 @@ const std = @import("std"); const Allocator = std.mem.Allocator; -const Lexed = @import("lexer/Lexed.zig"); +const Token = @import("lexer/Token.zig"); const Lexer = @import("lexer/Lexer.zig"); const Element = @import("dom/Element.zig"); const parser = @import("parser.zig"); @@ -10,7 +10,7 @@ const testing = @import("testing.zig"); const doTest = testing.do; const doTestError = testing.doError; -pub const Error = content.Error || link.Error || Lexer.Error; +pub const Error = content.Error || link.Error || Lexer.Error || Allocator.Error; pub fn parse(alloc: Allocator, l: *Lexer) Error!Element { var el = try Element.init(alloc, .content, "p"); @@ -19,8 +19,7 @@ pub fn parse(alloc: Allocator, l: *Lexer) Error!Element { switch (kind) { // because nextKind returns only an hint for the next rune .weak_delimiter => { - var v = (try l.next(alloc)).?; - defer v.deinit(); + const v = l.next().?; if (v.kind == .strong_delimiter) return el; const next = l.nextKind() orelse return el; switch (next) { -- cgit v1.2.3