diff --git a/Userland/Libraries/LibGfx/VectorN.h b/Userland/Libraries/LibGfx/VectorN.h index abbe3372bb..56f5aafa02 100644 --- a/Userland/Libraries/LibGfx/VectorN.h +++ b/Userland/Libraries/LibGfx/VectorN.h @@ -31,9 +31,6 @@ namespace Gfx { template requires(N >= 2 && N <= 4) class VectorN final { - template - friend class VectorN; - static_assert(LOOP_UNROLL_N >= N, "Unroll the entire loop for performance."); public: @@ -71,7 +68,7 @@ public: { UNROLL_LOOP for (auto i = 0u; i < N; ++i) - m_data[i] += other.m_data[i]; + m_data[i] += other.data()[i]; return *this; } @@ -79,7 +76,7 @@ public: { UNROLL_LOOP for (auto i = 0u; i < N; ++i) - m_data[i] -= other.m_data[i]; + m_data[i] -= other.data()[i]; return *this; } @@ -96,7 +93,7 @@ public: VectorN result; UNROLL_LOOP for (auto i = 0u; i < N; ++i) - result.m_data[i] = m_data[i] + other.m_data[i]; + result.m_data[i] = m_data[i] + other.data()[i]; return result; } @@ -105,7 +102,7 @@ public: VectorN result; UNROLL_LOOP for (auto i = 0u; i < N; ++i) - result.m_data[i] = m_data[i] - other.m_data[i]; + result.m_data[i] = m_data[i] - other.data()[i]; return result; } @@ -114,7 +111,7 @@ public: VectorN result; UNROLL_LOOP for (auto i = 0u; i < N; ++i) - result.m_data[i] = m_data[i] * other.m_data[i]; + result.m_data[i] = m_data[i] * other.data()[i]; return result; } @@ -132,7 +129,7 @@ public: VectorN result; UNROLL_LOOP for (auto i = 0u; i < N; ++i) - result.m_data[i] = m_data[i] / other.m_data[i]; + result.m_data[i] = m_data[i] / other.data()[i]; return result; } @@ -161,7 +158,7 @@ public: T result {}; UNROLL_LOOP for (auto i = 0u; i < N; ++i) - result += m_data[i] * other.m_data[i]; + result += m_data[i] * other.data()[i]; return result; } @@ -238,13 +235,16 @@ public: UNROLL_LOOP for (auto i = 0u; i < N; ++i) { if constexpr (IsSame) - result.m_data[i] = static_cast(lrintf(m_data[i])); + result.data()[i] = static_cast(lrintf(m_data[i])); else - result.m_data[i] = static_cast(lrint(m_data[i])); + result.data()[i] = static_cast(lrint(m_data[i])); } return result; } + auto& data() { return m_data; } + auto const& data() const { return m_data; } + private: AK::Array m_data; };