From dfe002cfd4282361ee622a5ec2e17d8968bf84e4 Mon Sep 17 00:00:00 2001 From: Jelle Raaijmakers Date: Sun, 8 May 2022 01:48:16 +0200 Subject: [PATCH] LibGfx: Use `VectorN` dot product of self for `length()` No functional changes. --- Userland/Libraries/LibGfx/VectorN.h | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Userland/Libraries/LibGfx/VectorN.h b/Userland/Libraries/LibGfx/VectorN.h index 56f5aafa02..0ef9d383e1 100644 --- a/Userland/Libraries/LibGfx/VectorN.h +++ b/Userland/Libraries/LibGfx/VectorN.h @@ -201,11 +201,7 @@ public: [[nodiscard]] constexpr T length() const { - T squared_sum {}; - UNROLL_LOOP - for (auto i = 0u; i < N; ++i) - squared_sum += m_data[i] * m_data[i]; - return AK::sqrt(squared_sum); + return AK::sqrt(dot(*this)); } [[nodiscard]] constexpr VectorN<2, T> xy() const requires(N >= 3)