stefan pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=a486671bce76e405a8d7261f19b0f67ca678f0c4

commit a486671bce76e405a8d7261f19b0f67ca678f0c4
Author: Stefan Schmidt <ste...@osg.samsung.com>
Date:   Fri Nov 27 00:13:04 2015 +0100

    eina_matrix: optimize multiply and inverse calls by actually using the 
shortcut
    
    We had this nice shortcuts for multiply and inverse with the identity 
matrix.
    Pity we never used it! The EINA_MATRIX_TYPE_IDENTITY is coming from an enum
    without and direct assignments to its internals. Being the first item in the
    enum it is most likely will be 0 which makes the whole bitwise AND zero and 
thus
    the optimized path will never get called. If our compiler now decides hew 
wants
    to handle enums differently and does not assign the 0 to the first item this
    bitwise operation will be even more screwed. What we really want is to 
check is
    if the type we get for the matrix matches EINA_MATRIX_TYPE_IDENTITY. So 
better
    do this. Made me look into matrix multply and inverse. Fun!
    
    Thanks to smatch for poiting this out.
---
 src/lib/eina/eina_matrix.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/lib/eina/eina_matrix.c b/src/lib/eina/eina_matrix.c
index 90493d3..7a1469c 100644
--- a/src/lib/eina/eina_matrix.c
+++ b/src/lib/eina/eina_matrix.c
@@ -991,13 +991,13 @@ EAPI void
 eina_matrix4_multiply(Eina_Matrix4 *out, const Eina_Matrix4 *mat_a,
                            const Eina_Matrix4 *mat_b)
 {
-   if (eina_matrix4_type_get(mat_a) & EINA_MATRIX_TYPE_IDENTITY)
+   if (eina_matrix4_type_get(mat_a) == EINA_MATRIX_TYPE_IDENTITY)
      {
         eina_matrix4_copy(out, mat_b);
         return;
      }
 
-   if (eina_matrix4_type_get(mat_b) & EINA_MATRIX_TYPE_IDENTITY)
+   if (eina_matrix4_type_get(mat_b) == EINA_MATRIX_TYPE_IDENTITY)
      {
         eina_matrix4_copy(out, mat_a);
         return;
@@ -1085,13 +1085,13 @@ eina_matrix3_copy(Eina_Matrix3 *dst, const Eina_Matrix3 
*src)
 EAPI void
 eina_matrix3_multiply(Eina_Matrix3 *out, const Eina_Matrix3 *mat_a, const 
Eina_Matrix3 *mat_b)
 {
-   if (eina_matrix3_type_get(mat_a) & EINA_MATRIX_TYPE_IDENTITY)
+   if (eina_matrix3_type_get(mat_a) == EINA_MATRIX_TYPE_IDENTITY)
      {
         eina_matrix3_copy(out, mat_b);
         return;
      }
 
-   if (eina_matrix3_type_get(mat_b) & EINA_MATRIX_TYPE_IDENTITY)
+   if (eina_matrix3_type_get(mat_b) == EINA_MATRIX_TYPE_IDENTITY)
      {
         eina_matrix3_copy(out, mat_a);
         return;
@@ -1206,7 +1206,7 @@ eina_matrix2_inverse(Eina_Matrix2 *out, const 
Eina_Matrix2 *mat)
 {
    double         det;
 
-   if (eina_matrix2_type_get(mat) & EINA_MATRIX_TYPE_IDENTITY)
+   if (eina_matrix2_type_get(mat) == EINA_MATRIX_TYPE_IDENTITY)
      {
         eina_matrix2_copy(out, mat);
         return;
@@ -1250,13 +1250,13 @@ eina_matrix2_copy(Eina_Matrix2 *dst, const Eina_Matrix2 
*src)
 EAPI void
 eina_matrix2_multiply(Eina_Matrix2 *out, const Eina_Matrix2 *mat_a, const 
Eina_Matrix2 *mat_b)
 {
-   if (eina_matrix2_type_get(mat_a) & EINA_MATRIX_TYPE_IDENTITY)
+   if (eina_matrix2_type_get(mat_a) == EINA_MATRIX_TYPE_IDENTITY)
      {
         eina_matrix2_copy(out, mat_b);
         return;
      }
 
-   if (eina_matrix2_type_get(mat_b) & EINA_MATRIX_TYPE_IDENTITY)
+   if (eina_matrix2_type_get(mat_b) == EINA_MATRIX_TYPE_IDENTITY)
      {
         eina_matrix2_copy(out, mat_a);
         return;

-- 


Reply via email to