eolian: cache function in implements where possible to get O(1) lookup

This commit is contained in:
Daniel Kolesa 2014-09-04 15:15:38 +01:00
parent 8d9bae1172
commit 0c0d639693
3 changed files with 22 additions and 0 deletions

View File

@ -253,6 +253,7 @@ _get_impl_func(Eolian_Class *cl, Eolian_Implement *impl,
impl->klass = cl;
*foo_id = (Eolian_Function*)eolian_class_function_get_by_name(cl, imstr,
ftype);
impl->foo_id = *foo_id;
return !!*foo_id;
}
@ -353,6 +354,7 @@ _db_build_implement(Eolian_Class *cl, Eolian_Function *foo_id)
eina_stringshare_ref(impl->base.file);
impl->klass = cl;
impl->foo_id = foo_id;
impl->full_name = eina_stringshare_printf("%s.%s", cl->full_name,
foo_id->name);

View File

@ -34,6 +34,22 @@ eolian_implement_function_get(const Eolian_Implement *impl,
Eolian_Function_Type *func_type)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(impl, NULL);
if (impl->foo_id)
{
if (!func_type)
return impl->foo_id;
if (impl->is_prop_get)
*func_type = EOLIAN_PROP_GET;
else if (impl->is_prop_set)
*func_type = EOLIAN_PROP_SET;
else
*func_type = eolian_function_type_get(impl->foo_id);
return impl->foo_id;
}
const Eolian_Class *klass = eolian_implement_class_get(impl);
if (!klass)
return NULL;
@ -67,6 +83,9 @@ eolian_implement_function_get(const Eolian_Implement *impl,
else
*func_type = tp;
}
((Eolian_Implement*)impl)->foo_id = fid;
return fid;
}

View File

@ -164,6 +164,7 @@ struct _Eolian_Implement
{
Eolian_Object base;
const Eolian_Class *klass;
const Eolian_Function *foo_id;
Eina_Stringshare *full_name;
Eina_Bool is_virtual :1;
Eina_Bool is_prop_get :1;