mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-03-22 04:34:44 +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 });
|
_ = 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;
|
const testing = std.testing;
|
||||||
|
|
||||||
test "arena pool - basic acquire and use" {
|
test "arena pool - basic acquire and use" {
|
||||||
|
|||||||
@@ -90,10 +90,7 @@ fn rebuildIfDirty(self: *StyleManager) !void {
|
|||||||
|
|
||||||
self.dirty = false;
|
self.dirty = false;
|
||||||
const item_count = self.rules.items.len;
|
const item_count = self.rules.items.len;
|
||||||
|
self.page._session.arena_pool.resetRetain(self.arena);
|
||||||
const arena: *std.heap.ArenaAllocator = @ptrCast(@alignCast(self.arena.ptr));
|
|
||||||
_ = arena.reset(.retain_capacity);
|
|
||||||
|
|
||||||
self.rules = try .initCapacity(self.arena, item_count);
|
self.rules = try .initCapacity(self.arena, item_count);
|
||||||
const sheets = self.page.document._style_sheets orelse return;
|
const sheets = self.page.document._style_sheets orelse return;
|
||||||
for (sheets._sheets.items) |sheet| {
|
for (sheets._sheets.items) |sheet| {
|
||||||
|
|||||||
Reference in New Issue
Block a user