From d8e8293b7e188383b95ca97e88db82e2d7a9bed9 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 2 Mar 2024 11:41:31 +0100 Subject: [PATCH] LibWeb: Add PercentageOr::to_px() fast path for absolute lengths We can avoid round-tripping through a temporary Length in the simple case here. --- Userland/Libraries/LibWeb/CSS/PercentageOr.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Userland/Libraries/LibWeb/CSS/PercentageOr.h b/Userland/Libraries/LibWeb/CSS/PercentageOr.h index 77046ac22c6..a6cf565e560 100644 --- a/Userland/Libraries/LibWeb/CSS/PercentageOr.h +++ b/Userland/Libraries/LibWeb/CSS/PercentageOr.h @@ -97,6 +97,12 @@ public: CSSPixels to_px(Layout::Node const& layout_node, CSSPixels reference_value) const { + if constexpr (IsSame) { + if (auto const* length = m_value.template get_pointer()) { + if (length->is_absolute()) + return length->absolute_length_to_px(); + } + } return resolved(layout_node, reference_value).to_px(layout_node); }