浏览代码

LibGfx: Use `VectorN` dot product of self for `length()`

No functional changes.
Jelle Raaijmakers 3 年之前
父节点
当前提交
dfe002cfd4
共有 1 个文件被更改,包括 1 次插入5 次删除
  1. 1 5
      Userland/Libraries/LibGfx/VectorN.h

+ 1 - 5
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)