Use std::{min|max}

A new clang-tidy-18 check led me to this. These files already use
<algorithm> so we might as well use these functions where appropriate.
This commit is contained in:
Chris Thrasher 2024-02-26 13:21:21 -07:00
parent 2a48b34386
commit aa3d0b7ba5
2 changed files with 5 additions and 10 deletions

View File

@ -276,8 +276,7 @@ float Text::getOutlineThickness() const
Vector2f Text::findCharacterPos(std::size_t index) const
{
// Adjust the index if it's out of range
if (index > m_string.getSize())
index = m_string.getSize();
index = std::min(index, m_string.getSize());
// Precompute the variables needed by the algorithm
const bool isBold = m_style & Bold;

View File

@ -313,14 +313,10 @@ bool Texture::loadFromImage(const Image& image, const IntRect& area)
// Adjust the rectangle to the size of the image
IntRect rectangle = area;
if (rectangle.left < 0)
rectangle.left = 0;
if (rectangle.top < 0)
rectangle.top = 0;
if (rectangle.left + rectangle.width > width)
rectangle.width = width - rectangle.left;
if (rectangle.top + rectangle.height > height)
rectangle.height = height - rectangle.top;
rectangle.left = std::max(rectangle.left, 0);
rectangle.top = std::max(rectangle.top, 0);
rectangle.width = std::min(rectangle.width, width - rectangle.left);
rectangle.height = std::min(rectangle.height, height - rectangle.top);
// Create the texture and upload the pixels
if (create(Vector2u(rectangle.getSize())))