@@ -52,13 +52,13 @@ pub const MatchByTagName = struct {
5252 tag : []const u8 ,
5353 is_wildcard : bool ,
5454
55- fn init (arena : Allocator , tag_name : []const u8 ) ! MatchByTagName {
55+ fn init (tag_name : []const u8 ) MatchByTagName {
5656 if (std .mem .eql (u8 , tag_name , "*" )) {
5757 return .{ .tag = "*" , .is_wildcard = true };
5858 }
5959
6060 return .{
61- .tag = try arena . dupe ( u8 , tag_name ) ,
61+ .tag = tag_name ,
6262 .is_wildcard = false ,
6363 };
6464 }
@@ -69,15 +69,14 @@ pub const MatchByTagName = struct {
6969};
7070
7171pub fn HTMLCollectionByTagName (
72- arena : Allocator ,
7372 root : ? * parser.Node ,
7473 tag_name : []const u8 ,
7574 opts : Opts ,
76- ) ! HTMLCollection {
77- return HTMLCollection {
75+ ) HTMLCollection {
76+ return . {
7877 .root = root ,
7978 .walker = .{ .walkerDepthFirst = .{} },
80- .matcher = .{ .matchByTagName = try MatchByTagName .init (arena , tag_name ) },
79+ .matcher = .{ .matchByTagName = MatchByTagName .init (tag_name ) },
8180 .mutable = opts .mutable ,
8281 .include_root = opts .include_root ,
8382 };
@@ -86,9 +85,9 @@ pub fn HTMLCollectionByTagName(
8685pub const MatchByClassName = struct {
8786 class_names : []const u8 ,
8887
89- fn init (arena : Allocator , class_names : []const u8 ) ! MatchByClassName {
88+ fn init (class_names : []const u8 ) ! MatchByClassName {
9089 return .{
91- .class_names = try arena . dupe ( u8 , class_names ) ,
90+ .class_names = class_names ,
9291 };
9392 }
9493
@@ -107,15 +106,14 @@ pub const MatchByClassName = struct {
107106};
108107
109108pub fn HTMLCollectionByClassName (
110- arena : Allocator ,
111109 root : ? * parser.Node ,
112- classNames : []const u8 ,
110+ class_names : []const u8 ,
113111 opts : Opts ,
114112) ! HTMLCollection {
115113 return HTMLCollection {
116114 .root = root ,
117115 .walker = .{ .walkerDepthFirst = .{} },
118- .matcher = .{ .matchByClassName = try MatchByClassName .init (arena , classNames ) },
116+ .matcher = .{ .matchByClassName = try MatchByClassName .init (class_names ) },
119117 .mutable = opts .mutable ,
120118 .include_root = opts .include_root ,
121119 };
@@ -124,10 +122,8 @@ pub fn HTMLCollectionByClassName(
124122pub const MatchByName = struct {
125123 name : []const u8 ,
126124
127- fn init (arena : Allocator , name : []const u8 ) ! MatchByName {
128- return .{
129- .name = try arena .dupe (u8 , name ),
130- };
125+ fn init (name : []const u8 ) ! MatchByName {
126+ return .{ .name = name };
131127 }
132128
133129 pub fn match (self : MatchByName , node : * parser.Node ) ! bool {
@@ -138,15 +134,14 @@ pub const MatchByName = struct {
138134};
139135
140136pub fn HTMLCollectionByName (
141- arena : Allocator ,
142137 root : ? * parser.Node ,
143138 name : []const u8 ,
144139 opts : Opts ,
145140) ! HTMLCollection {
146141 return HTMLCollection {
147142 .root = root ,
148143 .walker = .{ .walkerDepthFirst = .{} },
149- .matcher = .{ .matchByName = try MatchByName .init (arena , name ) },
144+ .matcher = .{ .matchByName = try MatchByName .init (name ) },
150145 .mutable = opts .mutable ,
151146 .include_root = opts .include_root ,
152147 };
@@ -203,8 +198,8 @@ pub fn HTMLCollectionChildren(
203198 };
204199}
205200
206- pub fn HTMLCollectionEmpty () ! HTMLCollection {
207- return HTMLCollection {
201+ pub fn HTMLCollectionEmpty () HTMLCollection {
202+ return . {
208203 .root = null ,
209204 .walker = .{ .walkerNone = .{} },
210205 .matcher = .{ .matchFalse = .{} },
@@ -226,14 +221,11 @@ pub const MatchByLinks = struct {
226221 }
227222};
228223
229- pub fn HTMLCollectionByLinks (
230- root : ? * parser.Node ,
231- opts : Opts ,
232- ) ! HTMLCollection {
233- return HTMLCollection {
224+ pub fn HTMLCollectionByLinks (root : ? * parser.Node , opts : Opts ) HTMLCollection {
225+ return .{
234226 .root = root ,
235227 .walker = .{ .walkerDepthFirst = .{} },
236- .matcher = .{ .matchByLinks = MatchByLinks {} },
228+ .matcher = .{ .matchByLinks = . {} },
237229 .mutable = opts .mutable ,
238230 .include_root = opts .include_root ,
239231 };
@@ -252,14 +244,11 @@ pub const MatchByAnchors = struct {
252244 }
253245};
254246
255- pub fn HTMLCollectionByAnchors (
256- root : ? * parser.Node ,
257- opts : Opts ,
258- ) ! HTMLCollection {
259- return HTMLCollection {
247+ pub fn HTMLCollectionByAnchors (root : ? * parser.Node , opts : Opts ) HTMLCollection {
248+ return .{
260249 .root = root ,
261250 .walker = .{ .walkerDepthFirst = .{} },
262- .matcher = .{ .matchByAnchors = MatchByAnchors {} },
251+ .matcher = .{ .matchByAnchors = . {} },
263252 .mutable = opts .mutable ,
264253 .include_root = opts .include_root ,
265254 };
0 commit comments