From 8c863ad9590da806b5367a27a346182a072d10da Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 17 Sep 2021 13:35:17 +0200 Subject: [PATCH] LibGfx: Make Path::bounding_box() and Path::split_lines() const Use a const_cast internally when segmentizing. As far as clients are concerned, these are const operations. --- Userland/Libraries/LibGfx/Path.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Userland/Libraries/LibGfx/Path.h b/Userland/Libraries/LibGfx/Path.h index f5f3988a83..afda4d00f7 100644 --- a/Userland/Libraries/LibGfx/Path.h +++ b/Userland/Libraries/LibGfx/Path.h @@ -169,10 +169,10 @@ public: }; const NonnullRefPtrVector& segments() const { return m_segments; } - const auto& split_lines() + auto& split_lines() const { if (!m_split_lines.has_value()) { - segmentize_path(); + const_cast(this)->segmentize_path(); VERIFY(m_split_lines.has_value()); } return m_split_lines.value(); @@ -184,10 +184,10 @@ public: m_split_lines.clear(); } - const Gfx::FloatRect& bounding_box() + Gfx::FloatRect const& bounding_box() const { if (!m_bounding_box.has_value()) { - segmentize_path(); + const_cast(this)->segmentize_path(); VERIFY(m_bounding_box.has_value()); } return m_bounding_box.value();