From afebc372b99757ccebe8fc83f54665924ad4ae9f Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Tue, 29 Mar 2022 18:30:32 +0200 Subject: [PATCH] LibGfx: Use llroundf() in Rect::to_rounded() No need to drag the values through a float-to-double conversion. --- Userland/Libraries/LibGfx/Rect.h | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/Userland/Libraries/LibGfx/Rect.h b/Userland/Libraries/LibGfx/Rect.h index e52319f42e..57b7d249c6 100644 --- a/Userland/Libraries/LibGfx/Rect.h +++ b/Userland/Libraries/LibGfx/Rect.h @@ -700,12 +700,21 @@ public: template [[nodiscard]] ALWAYS_INLINE Rect to_rounded() const { - return { - static_cast(llroundd(x())), - static_cast(llroundd(y())), - static_cast(llroundd(width())), - static_cast(llroundd(height())), - }; + if constexpr (IsSame) { + return { + static_cast(llroundf(x())), + static_cast(llroundf(y())), + static_cast(llroundf(width())), + static_cast(llroundf(height())), + }; + } else { + return { + static_cast(llroundd(x())), + static_cast(llroundd(y())), + static_cast(llroundd(width())), + static_cast(llroundd(height())), + }; + } } [[nodiscard]] String to_string() const;