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

LibGfx: Prevent calling to_type<T>() on Line/Point/Rect/Size<T>

Also, add `Line::to_type<T>()` since that was missing.

Calling to_type() with the same type as the existing object accomplishes
nothing except wasting some cycles and making the code more verbose,
and it is hard to spot. Nobody does this in the code currently
(yay!) but I made this mistake repeatedly when doing my step-by-step
CSS Pixels conversion, so let's make it easier to catch them.
This commit is contained in:
Sam Atkins 2022-11-24 16:04:45 +00:00 committed by Andreas Kling
parent 34fd5cb206
commit 234bc0c237
4 changed files with 13 additions and 3 deletions

View file

@ -949,7 +949,8 @@ public:
}
template<typename U>
[[nodiscard]] ALWAYS_INLINE Rect<U> to_type() const
requires(!IsSame<T, U>)
[[nodiscard]] ALWAYS_INLINE Rect<U> to_type() const
{
return Rect<U>(*this);
}