mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-25 17:25:08 +02:00
Pre-compute per-observer values (root node, root paintable, root bounds, is_implicit_root, root_is_element) once before the per-target loop instead of recomputing them for each target. Add intersection_root_node() which returns GC::Ref<DOM::Node> without creating GC::Root wrappers. Previously, intersection_root() was called multiple times per target (in the skip condition check, in compute_intersection, and again in root_intersection_rectangle inside compute_intersection), each call creating GC::Root objects that require heap allocation via new RootImpl. Pass the pre-computed root bounds and root paintable into compute_intersection instead of having it call root_intersection_rectangle() and intersection_root() internally. For an observer watching N targets, this eliminates roughly 4N heap allocations per frame.