mirror of
https://github.com/SFML/SFML.git
synced 2025-02-16 21:38:00 +08:00
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:
parent
2a48b34386
commit
aa3d0b7ba5
@ -276,8 +276,7 @@ float Text::getOutlineThickness() const
|
|||||||
Vector2f Text::findCharacterPos(std::size_t index) const
|
Vector2f Text::findCharacterPos(std::size_t index) const
|
||||||
{
|
{
|
||||||
// Adjust the index if it's out of range
|
// Adjust the index if it's out of range
|
||||||
if (index > m_string.getSize())
|
index = std::min(index, m_string.getSize());
|
||||||
index = m_string.getSize();
|
|
||||||
|
|
||||||
// Precompute the variables needed by the algorithm
|
// Precompute the variables needed by the algorithm
|
||||||
const bool isBold = m_style & Bold;
|
const bool isBold = m_style & Bold;
|
||||||
|
@ -313,14 +313,10 @@ bool Texture::loadFromImage(const Image& image, const IntRect& area)
|
|||||||
|
|
||||||
// Adjust the rectangle to the size of the image
|
// Adjust the rectangle to the size of the image
|
||||||
IntRect rectangle = area;
|
IntRect rectangle = area;
|
||||||
if (rectangle.left < 0)
|
rectangle.left = std::max(rectangle.left, 0);
|
||||||
rectangle.left = 0;
|
rectangle.top = std::max(rectangle.top, 0);
|
||||||
if (rectangle.top < 0)
|
rectangle.width = std::min(rectangle.width, width - rectangle.left);
|
||||||
rectangle.top = 0;
|
rectangle.height = std::min(rectangle.height, height - rectangle.top);
|
||||||
if (rectangle.left + rectangle.width > width)
|
|
||||||
rectangle.width = width - rectangle.left;
|
|
||||||
if (rectangle.top + rectangle.height > height)
|
|
||||||
rectangle.height = height - rectangle.top;
|
|
||||||
|
|
||||||
// Create the texture and upload the pixels
|
// Create the texture and upload the pixels
|
||||||
if (create(Vector2u(rectangle.getSize())))
|
if (create(Vector2u(rectangle.getSize())))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user