Bug 1459403: Cleanup multiply(). r?hiro draft
authorEmilio Cobos Álvarez <emilio@crisal.io>
Sat, 26 May 2018 23:46:14 +0200
changeset 800298 479b88c6fe7ce322835b738aa1fec61f89383a98
parent 800297 ca93b91f002b17aa3d908625eb4d599986ebc067
child 800299 d91bde7831546b3687ca680bcc1cb6faa61b4a52
push id111314
push userbmo:emilio@crisal.io
push dateSat, 26 May 2018 22:27:44 +0000
reviewershiro
bugs1459403
milestone62.0a1
Bug 1459403: Cleanup multiply(). r?hiro We assign all the members, the result matrix doesn't really need to be any clone of a. MozReview-Commit-ID: 3NkhvyfqQL
servo/components/style/properties/helpers/animated_properties.mako.rs
--- a/servo/components/style/properties/helpers/animated_properties.mako.rs
+++ b/servo/components/style/properties/helpers/animated_properties.mako.rs
@@ -2210,26 +2210,27 @@ impl From<MatrixDecomposed3D> for Matrix
         % endfor
 
         matrix
     }
 }
 
 // Multiplication of two 4x4 matrices.
 fn multiply(a: Matrix3D, b: Matrix3D) -> Matrix3D {
-    let mut a_clone = a;
+    Matrix3D {
     % for i in range(1, 5):
-        % for j in range(1, 5):
-            a_clone.m${i}${j} = (a.m${i}1 * b.m1${j}) +
-                               (a.m${i}2 * b.m2${j}) +
-                               (a.m${i}3 * b.m3${j}) +
-                               (a.m${i}4 * b.m4${j});
-        % endfor
+    % for j in range(1, 5):
+        m${i}${j}:
+            a.m${i}1 * b.m1${j} +
+            a.m${i}2 * b.m2${j} +
+            a.m${i}3 * b.m3${j} +
+            a.m${i}4 * b.m4${j},
     % endfor
-    a_clone
+    % endfor
+    }
 }
 
 impl Matrix3D {
     fn is_3d(&self) -> bool {
         self.m13 != 0.0 || self.m14 != 0.0 ||
         self.m23 != 0.0 || self.m24 != 0.0 ||
         self.m31 != 0.0 || self.m32 != 0.0 || self.m33 != 1.0 || self.m34 != 0.0 ||
         self.m43 != 0.0 || self.m44 != 1.0