From f521e2ec48ea982746c7d3f64eb6f33853ec0610 Mon Sep 17 00:00:00 2001 From: LDprg <71488985+LDprg@users.noreply.github.com> Date: Tue, 6 Sep 2022 09:59:21 +0200 Subject: [PATCH] fix formatting and add comment --- src/SFML/System/Vector2.cpp | 5 +++-- src/SFML/System/Vector3.cpp | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/SFML/System/Vector2.cpp b/src/SFML/System/Vector2.cpp index cd2272a2..72183b26 100644 --- a/src/SFML/System/Vector2.cpp +++ b/src/SFML/System/Vector2.cpp @@ -106,8 +106,9 @@ template T Vector2::length() const { static_assert(std::is_floating_point_v, "Vector2::length() is only supported for floating point types"); - - return std::sqrt(x*x + y*y); + + // don't use std::hypot because of slow performance + return std::sqrt(x * x + y * y); } } // namespace sf diff --git a/src/SFML/System/Vector3.cpp b/src/SFML/System/Vector3.cpp index 89cb5106..392a8138 100644 --- a/src/SFML/System/Vector3.cpp +++ b/src/SFML/System/Vector3.cpp @@ -48,7 +48,8 @@ T Vector3::length() const { static_assert(std::is_floating_point_v, "Vector3::length() is only supported for floating point types"); - return std::sqrt(x*x + y*y + z*z); + // don't use std::hypot because of slow performance + return std::sqrt(x * x + y * y + z * z); } } // namespace sf