eo2: fix obj_data retrieval and speed up
authorJérémy Zurcher <jeremy@asynk.ch>
Wed, 10 Jul 2013 07:24:59 +0000 (09:24 +0200)
committerTom Hacohen <tom@stosb.com>
Thu, 10 Apr 2014 03:20:15 +0000 (04:20 +0100)
obj_data which is built from func->src not obj->klass.
replace eo2_func_get() and eo2_data_scope_get() calls
with one call to eo2_call_resolve().

src/lib/eo/Eo.h
src/lib/eo/eo.c

index d522d98..ef395a8 100644 (file)
@@ -594,17 +594,23 @@ EAPI Eina_Bool eo_shutdown(void);
 
 typedef struct _Eo_Internal _Eo;
 
-#define EO_FUNC_CALL() func(objid, obj_data)
-#define EO_FUNC_CALLV(...) func(objid, obj_data, __VA_ARGS__)
+typedef struct _Eo2_Op_Call_Data
+{
+   void *func;
+   void *data;
+} Eo2_Op_Call_Data;
+
+#define EO_FUNC_CALL() func(objid, call.data)
+#define EO_FUNC_CALLV(...) func(objid, call.data, __VA_ARGS__)
 
 /* XXX: Essential, because we need to adjust objid for comp objects. */
 #define EO_FUNC_BODY(Name, Ret, Id, Func, DefRet) \
 Ret \
 Name(_Eo *obj, Eo *objid) \
 { \
-   Ret (*func)(Eo *, void *obj_data) = eo2_func_get(obj, Id(Name)); \
-   if (!func) return DefRet; \
-   void *obj_data = eo2_data_scope_get(obj); \
+   Eo2_Op_Call_Data call; \
+   if (!eo2_call_resolve(obj, Id(Name), &call)) return DefRet; \
+   Ret (*func)(Eo *, void *obj_data) = call.func; \
    return Func; \
 }
 
@@ -612,17 +618,16 @@ Name(_Eo *obj, Eo *objid) \
 Ret \
 Name(_Eo *obj, Eo *objid, __VA_ARGS__) \
 { \
-   Ret (*func)(Eo *, void *obj_data, __VA_ARGS__) = eo2_func_get(obj, Id(Name)); \
-   if (!func) return DefRet; \
-   void *obj_data = eo2_data_scope_get(obj); \
+   Eo2_Op_Call_Data call; \
+   if (!eo2_call_resolve(obj, Id(Name), &call)) return DefRet; \
+   Ret (*func)(Eo *, void *obj_data, __VA_ARGS__) = call.func; \
    return Func; \
 }
 
 
 EAPI _Eo * eo2_do_start(Eo *obj_id);
-EAPI void * eo2_data_scope_get(const _Eo *obj);
-#define eo2_func_get(obj_id, op) eo2_func_get_internal(obj_id, NULL, op)
-EAPI void * eo2_func_get_internal(_Eo *obj, const Eo_Class *klass, Eo_Op op);
+#define eo2_call_resolve(obj_id, op, call) eo2_call_resolve_internal(obj_id, NULL, op, call)
+EAPI Eina_Bool eo2_call_resolve_internal(_Eo *obj, const Eo_Class *klass, Eo_Op op, Eo2_Op_Call_Data *call);
 
 /* FIXME: Don't use this unref, use an internal one. Reduce id resolution. */
 
index 7d557f7..532dbcd 100644 (file)
@@ -263,36 +263,28 @@ eo2_do_start(Eo *obj_id)
    return obj;
 }
 
-EAPI void *eo2_data_scope_get(const _Eo *obj)
+EAPI Eina_Bool
+eo2_call_resolve_internal(_Eo *obj, const Eo_Class *klass_id, Eo_Op op, Eo2_Op_Call_Data *call)
 {
-   return _eo_data_scope_get(obj, obj->klass);
-}
+   const _Eo_Class *klass;
+   const op_type_funcs *func;
 
-static void *
-_eo2_func_get(const _Eo_Class *cur_klass, Eo_Op op)
-{
+   if (klass_id)
+      klass = _eo_class_pointer_get(klass_id);
+   else
+      klass = obj->klass;
+
+   func = _eo_kls_itr_func_get(klass, op);
+   if (EINA_LIKELY(func != NULL))
      {
-        const op_type_funcs *func = _eo_kls_itr_func_get(cur_klass, op);
-        if (EINA_LIKELY(func != NULL))
-          {
-             return func->func;
-          }
+        call->func = func->func;
+        call->data = _eo_data_scope_get(obj, func->src);
+        return EINA_TRUE;
      }
 
    /* Try composite objects */
    /* FIXME!!! */
-   return NULL;
-}
-
-EAPI void *
-eo2_func_get_internal(_Eo *obj, const Eo_Class *klass_id, Eo_Op op)
-{
-   const _Eo_Class *klass;
-   if (klass_id)
-      klass = _eo_class_pointer_get(klass_id);
-   else
-      klass = obj->klass;
-   return _eo2_func_get(klass, op);
+   return EINA_FALSE;
 }
 
 #define _EO_OP_ERR_NO_OP_PRINT(file, line, op, klass) \