speed up code by 10 times replacing hypot with sqrt
This commit is contained in:
parent
45986c6400
commit
0584448a06
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user