cedric pushed a commit to branch master.

commit 2d9ec2159c6a2fa5e214a07a3d4de623b54fa1c3
Author: Cedric Bail <[email protected]>
Date:   Thu Apr 11 11:58:53 2013 +0900

    eo: let's cache this value.
---
 src/lib/eo/eo.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c
index 692ab3e..9ec28a1 100644
--- a/src/lib/eo/eo.c
+++ b/src/lib/eo/eo.c
@@ -20,6 +20,8 @@ static Eo_Class_Id _eo_classes_last_id;
 static Eina_Bool _eo_init_count = 0;
 static Eo_Op _eo_ops_last_id = 0;
 
+static size_t _eo_sz = 0;
+
 static void _eo_condtor_reset(Eo *obj);
 static inline void *_eo_data_get(const Eo *obj, const Eo_Class *klass);
 static inline Eo *_eo_ref(Eo *obj);
@@ -1369,15 +1371,13 @@ _eo_data_get(const Eo *obj, const Eo_Class *klass)
              while (doff_itr->klass)
                {
                   if (doff_itr->klass == klass)
-                    return ((char *) obj) + EO_ALIGN_SIZE(sizeof(*obj)) +
-                       doff_itr->offset;
+                    return ((char *) obj) + _eo_sz + doff_itr->offset;
                   doff_itr++;
                }
           }
         else
           {
-             return ((char *) obj) + EO_ALIGN_SIZE(sizeof(*obj)) +
-                klass->data_offset;
+             return ((char *) obj) + _eo_sz + klass->data_offset;
           }
      }
 
@@ -1420,6 +1420,8 @@ eo_init(void)
 
    eina_init();
 
+   _eo_sz = EO_ALIGN_SIZE(sizeof (Eo));
+
    _eo_classes = NULL;
    _eo_classes_last_id = EO_CLASS_IDS_FIRST - 1;
    _eo_ops_last_id = EO_OP_IDS_FIRST;

-- 

------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter

Reply via email to