eolian: cache function in implements where possible to get O(1) lookup
authorDaniel Kolesa <d.kolesa@samsung.com>
Thu, 4 Sep 2014 14:15:38 +0000 (15:15 +0100)
committerDaniel Kolesa <d.kolesa@samsung.com>
Thu, 4 Sep 2014 14:15:38 +0000 (15:15 +0100)
src/lib/eolian/database_fill.c
src/lib/eolian/database_implement_api.c
src/lib/eolian/eolian_database.h

index 9c4269f..d96cb7a 100644 (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);
 
index b0bdce2..b956c20 100644 (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;
 }
 
index 0b61e11..57a0665 100644 (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;