SimonSapin
changed the title
layout: Introduce
layout: reduce redundant atomic style borrows (4% faster layout)BoxFragmentWithStyle with long(er)-lived borrow
`BoxFragment` (indirectly) owns an `Arc<AtomicRefCell<ComputedStyle>>`. To access, `&ComputedStyle`, the `AtomicRefCell` must increment an atomic borrow counter and return a guard that decrements the counter when dropped. Layout code accesses the style in may places, but repeatdly borrowing and unborrowing the refcell creates additional traffic of the atomic borrow counter which may have some performance cost. The new `BoxFragmentWithStyle<'_>` struct packages a `&BoxFragment` with an already-borrowed guard for the style, so using it to repeatedly access the style is free. To start with, this is used in `display_list::BuilderForBoxFragment`. We can later extend its use in more places that repeatedly access style. Signed-off-by: Simon Sapin <simon@igalia.com>