From ef873b7b2983f833c251222402a309e1e39240fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Wed, 10 Jul 2013 09:24:59 +0200 Subject: [PATCH] eo2: fix obj_data retrieval and speed up 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 | 27 ++++++++++++++++----------- src/lib/eo/eo.c | 40 ++++++++++++++++------------------------ 2 files changed, 32 insertions(+), 35 deletions(-) diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index d522d98469..ef395a8d51 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -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. */ diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index 7d557f78eb..532dbcd850 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -263,36 +263,28 @@ eo2_do_start(Eo *obj_id) return obj; } -EAPI void *eo2_data_scope_get(const _Eo *obj) -{ - return _eo_data_scope_get(obj, obj->klass); -} - -static void * -_eo2_func_get(const _Eo_Class *cur_klass, Eo_Op op) -{ - { - const op_type_funcs *func = _eo_kls_itr_func_get(cur_klass, op); - if (EINA_LIKELY(func != NULL)) - { - return func->func; - } - } - - /* Try composite objects */ - /* FIXME!!! */ - return NULL; -} - -EAPI void * -eo2_func_get_internal(_Eo *obj, const Eo_Class *klass_id, Eo_Op op) +EAPI Eina_Bool +eo2_call_resolve_internal(_Eo *obj, const Eo_Class *klass_id, Eo_Op op, Eo2_Op_Call_Data *call) { const _Eo_Class *klass; + const op_type_funcs *func; + if (klass_id) klass = _eo_class_pointer_get(klass_id); else klass = obj->klass; - return _eo2_func_get(klass, op); + + func = _eo_kls_itr_func_get(klass, op); + if (EINA_LIKELY(func != NULL)) + { + call->func = func->func; + call->data = _eo_data_scope_get(obj, func->src); + return EINA_TRUE; + } + + /* Try composite objects */ + /* FIXME!!! */ + return EINA_FALSE; } #define _EO_OP_ERR_NO_OP_PRINT(file, line, op, klass) \