1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 11:07:45 +00:00

LibGfx: Use llroundf() in Rect<float>::to_rounded()

No need to drag the values through a float-to-double conversion.
This commit is contained in:
Andreas Kling 2022-03-29 18:30:32 +02:00
parent fdf1c3c2f1
commit afebc372b9

View file

@ -700,12 +700,21 @@ public:
template<typename U> template<typename U>
[[nodiscard]] ALWAYS_INLINE Rect<U> to_rounded() const [[nodiscard]] ALWAYS_INLINE Rect<U> to_rounded() const
{ {
return { if constexpr (IsSame<T, float>) {
static_cast<U>(llroundd(x())), return {
static_cast<U>(llroundd(y())), static_cast<U>(llroundf(x())),
static_cast<U>(llroundd(width())), static_cast<U>(llroundf(y())),
static_cast<U>(llroundd(height())), static_cast<U>(llroundf(width())),
}; static_cast<U>(llroundf(height())),
};
} else {
return {
static_cast<U>(llroundd(x())),
static_cast<U>(llroundd(y())),
static_cast<U>(llroundd(width())),
static_cast<U>(llroundd(height())),
};
}
} }
[[nodiscard]] String to_string() const; [[nodiscard]] String to_string() const;