1
0
mirror of https://github.com/SFML/SFML.git synced 2025-03-14 01:40:05 +08:00

speed up code by 10 times replacing hypot with sqrt

This commit is contained in:
LDprg 2022-09-06 09:25:23 +02:00 committed by Vittorio Romeo
parent 45986c6400
commit 0584448a06
2 changed files with 3 additions and 3 deletions
src/SFML/System

@ -106,8 +106,8 @@ template <typename T>
T Vector2<T>::length() const
{
static_assert(std::is_floating_point_v<T>, "Vector2::length() is only supported for floating point types");
return std::hypot(x, y);
return std::sqrt(x*x + y*y);
}
} // namespace sf

@ -48,7 +48,7 @@ T Vector3<T>::length() const
{
static_assert(std::is_floating_point_v<T>, "Vector3::length() is only supported for floating point types");
return std::hypot(x, y, z);
return std::sqrt(x*x + y*y + z*z);
}
} // namespace sf