From ee18912373cf1777d368f8e4f32a79ef85952c8e Mon Sep 17 00:00:00 2001 From: Ben Wiederhake Date: Sun, 10 Oct 2021 15:42:19 +0200 Subject: [PATCH] LibGfx: Implement copy-assign for Matrix This used to generate a warning about using a deprecated copy-assign, default-generated by the compiler, and deprecated because we hand- implement the copy-constructor. This warning is correct, since the default-generated copy-assign may or may not be as efficient as memcpy. This patch gets rid of the warning, and has either no performance impact or a slightly positive one. If this turns out to be wrong, we should probably also fix the copy-constructor. --- Userland/Libraries/LibGfx/Matrix.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Userland/Libraries/LibGfx/Matrix.h b/Userland/Libraries/LibGfx/Matrix.h index ac27853934..8c93956002 100644 --- a/Userland/Libraries/LibGfx/Matrix.h +++ b/Userland/Libraries/LibGfx/Matrix.h @@ -38,6 +38,12 @@ public: __builtin_memcpy(m_elements, other.elements(), sizeof(T) * N * N); } + Matrix& operator=(const Matrix& other) + { + __builtin_memcpy(m_elements, other.elements(), sizeof(T) * N * N); + return *this; + } + constexpr auto elements() const { return m_elements; } constexpr auto elements() { return m_elements; }