LibWeb: Do not calculate corner radii if no radius is set

The `as_corner()` and `floored_device_pixels()` functions popped up
frequently in profiles when selecting text on some Tweakers.net pages.
For every corner we're performing multiple device pixel calculations
regardless of whether any radius was actually set.

Add an early return if no radius is set. On my machine this reduces the
time taken in both `as_corner()` and `floored_device_pixels()` by 46%
(63% fewer calls).
This commit is contained in:
Jelle Raaijmakers 2025-03-19 10:55:22 +01:00 committed by Alexander Kalenik
parent cfeb916e61
commit c2e21d33eb
Notes: github-actions[bot] 2025-03-19 13:23:10 +00:00

View file

@ -93,6 +93,8 @@ struct BorderRadiiData {
inline CornerRadii as_corners(PaintContext const& context) const
{
if (!has_any_radius())
return {};
return CornerRadii {
top_left.as_corner(context),
top_right.as_corner(context),