Skip to content

Commit 191e9ba

Browse files
Merge pull request #954 from lightpanda-io/remove_managed_arraylist
Replace all std.ArrayList with std.ArrayListUnmanaged
2 parents 2c7b399 + a4d4da4 commit 191e9ba

File tree

8 files changed

+144
-122
lines changed

8 files changed

+144
-122
lines changed

src/browser/css/libdom_test.zig

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,31 @@ const std = @import("std");
2020
const css = @import("css.zig");
2121
const Node = @import("libdom.zig").Node;
2222
const parser = @import("../netsurf.zig");
23+
const Allocator = std.mem.Allocator;
2324

2425
const Matcher = struct {
25-
const Nodes = std.ArrayList(Node);
26+
const Nodes = std.ArrayListUnmanaged(Node);
2627

2728
nodes: Nodes,
29+
allocator: Allocator,
2830

29-
fn init(alloc: std.mem.Allocator) Matcher {
30-
return .{ .nodes = Nodes.init(alloc) };
31+
fn init(allocator: Allocator) Matcher {
32+
return .{
33+
.nodes = .empty,
34+
.allocator = allocator,
35+
};
3136
}
3237

3338
fn deinit(m: *Matcher) void {
34-
m.nodes.deinit();
39+
m.nodes.deinit(m.allocator);
3540
}
3641

3742
fn reset(m: *Matcher) void {
3843
m.nodes.clearRetainingCapacity();
3944
}
4045

4146
pub fn match(m: *Matcher, n: Node) !void {
42-
try m.nodes.append(n);
47+
try m.nodes.append(m.allocator, n);
4348
}
4449
};
4550

src/browser/css/match_test.zig

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,24 +84,28 @@ pub const Node = struct {
8484
};
8585

8686
const Matcher = struct {
87-
const Nodes = std.ArrayList(*const Node);
87+
const Nodes = std.ArrayListUnmanaged(*const Node);
8888

8989
nodes: Nodes,
90+
allocator: Allocator,
9091

91-
fn init(alloc: std.mem.Allocator) Matcher {
92-
return .{ .nodes = Nodes.init(alloc) };
92+
fn init(allocator: Allocator) Matcher {
93+
return .{
94+
.nodes = .empty,
95+
.allocator = allocator,
96+
};
9397
}
9498

9599
fn deinit(m: *Matcher) void {
96-
m.nodes.deinit();
100+
m.nodes.deinit(self.allocator);
97101
}
98102

99103
fn reset(m: *Matcher) void {
100104
m.nodes.clearRetainingCapacity();
101105
}
102106

103107
pub fn match(m: *Matcher, n: *const Node) !void {
104-
try m.nodes.append(n);
108+
try m.nodes.append(self.allocator, n);
105109
}
106110
};
107111

0 commit comments

Comments
 (0)