mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-03-21 20:24:42 +00:00
better encapsulate arena reset
This commit is contained in:
@@ -100,6 +100,11 @@ pub fn reset(_: *const ArenaPool, allocator: Allocator, retain: usize) void {
|
||||
_ = arena.reset(.{ .retain_with_limit = retain });
|
||||
}
|
||||
|
||||
pub fn resetRetain(_: *const ArenaPool, allocator: Allocator) void {
|
||||
const arena: *std.heap.ArenaAllocator = @ptrCast(@alignCast(allocator.ptr));
|
||||
_ = arena.reset(.retain_capacity);
|
||||
}
|
||||
|
||||
const testing = std.testing;
|
||||
|
||||
test "arena pool - basic acquire and use" {
|
||||
|
||||
@@ -90,10 +90,7 @@ fn rebuildIfDirty(self: *StyleManager) !void {
|
||||
|
||||
self.dirty = false;
|
||||
const item_count = self.rules.items.len;
|
||||
|
||||
const arena: *std.heap.ArenaAllocator = @ptrCast(@alignCast(self.arena.ptr));
|
||||
_ = arena.reset(.retain_capacity);
|
||||
|
||||
self.page._session.arena_pool.resetRetain(self.arena);
|
||||
self.rules = try .initCapacity(self.arena, item_count);
|
||||
const sheets = self.page.document._style_sheets orelse return;
|
||||
for (sheets._sheets.items) |sheet| {
|
||||
|
||||
Reference in New Issue
Block a user