# HG changeset patch # User Emmanuel Gil Peyrot # Date 1427569130 -3600 # Node ID 560b45a7d014e01018cccd236c29436c33ba22f5 # Parent 73f134f84c7f993fdceb2be24a0b6357a96e49b1 Don’t uselessly malloc() a matrix for multiply, the stack is here for that! diff --git a/pytouhou/utils/matrix.pyx b/pytouhou/utils/matrix.pyx --- a/pytouhou/utils/matrix.pyx +++ b/pytouhou/utils/matrix.pyx @@ -36,18 +36,17 @@ cdef Matrix *new_identity() nogil: cdef void mul(Matrix *mat1, Matrix *mat2) nogil: cdef float *d3 + cdef Matrix out - out = malloc(sizeof(Matrix)) d1 = mat1 d2 = mat2 - d3 = out + d3 = &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: