Explorar o código

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.
Ben Wiederhake %!s(int64=3) %!d(string=hai) anos
pai
achega
ee18912373
Modificáronse 1 ficheiros con 6 adicións e 0 borrados
  1. 6 0
      Userland/Libraries/LibGfx/Matrix.h

+ 6 - 0
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; }