fix: Buffer.rebalance on zig-0.15

This commit is contained in:
CJ van den Berg 2025-09-26 15:36:25 +02:00
parent 757096bfb3
commit 0f560ed3bc
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9

View file

@ -333,21 +333,21 @@ const Node = union(enum) {
}; };
} }
fn collect(self: *const Node, l: *ArrayList(*const Node)) !void { fn collect(self: *const Node, allocator: Allocator, l: *ArrayList(*const Node)) !void {
switch (self.*) { switch (self.*) {
.node => |*node| { .node => |*node| {
try node.left.collect(l); try node.left.collect(allocator, l);
try node.right.collect(l); try node.right.collect(allocator, l);
}, },
.leaf => (try l.addOne()).* = self, .leaf => (try l.addOne(allocator)).* = self,
} }
} }
fn collect_leaves(self: *const Node, allocator: Allocator) ![]*const Node { fn collect_leaves(self: *const Node, allocator: Allocator) ![]*const Node {
var leaves = ArrayList(*const Node).init(allocator); var leaves: ArrayList(*const Node) = .empty;
try leaves.ensureTotalCapacity(self.lines()); try leaves.ensureTotalCapacity(allocator, self.lines());
try self.collect(&leaves); try self.collect(allocator, &leaves);
return leaves.toOwnedSlice(); return leaves.toOwnedSlice(allocator);
} }
fn walk_const(self: *const Node, f: Walker.F, ctx: *anyopaque, metrics: Metrics) Walker { fn walk_const(self: *const Node, f: Walker.F, ctx: *anyopaque, metrics: Metrics) Walker {