changeset 613:560b45a7d014

Don’t uselessly malloc() a matrix for multiply, the stack is here for that!
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Sat, 28 Mar 2015 19:58:50 +0100
parents 73f134f84c7f
children 2cf518129725
files pytouhou/utils/matrix.pyx
diffstat 1 files changed, 3 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/pytouhou/utils/matrix.pyx	Thu Mar 26 20:20:37 2015 +0100
+++ b/pytouhou/utils/matrix.pyx	Sat Mar 28 19:58:50 2015 +0100
@@ -36,18 +36,17 @@
 
 cdef void mul(Matrix *mat1, Matrix *mat2) nogil:
     cdef float *d3
+    cdef Matrix out
 
-    out = <Matrix*> malloc(sizeof(Matrix))
     d1 = <float*>mat1
     d2 = <float*>mat2
-    d3 = <float*>out
+    d3 = <float*>&out
     for i in range(4):
         for j in range(4):
             d3[4*i+j] = 0
             for k in range(4):
                 d3[4*i+j] += d1[4*i+k] * d2[4*k+j]
-    memcpy(mat1, out, sizeof(Matrix))
-    free(out)
+    memcpy(mat1, &out, sizeof(Matrix))
 
 
 cdef void flip(Matrix *mat) nogil: