1/3 eina_model: lookup interfaces in the correct order.
authorbarbieri <barbieri@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Thu, 16 Feb 2012 19:30:23 +0000 (19:30 +0000)
committerbarbieri <barbieri@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Thu, 16 Feb 2012 19:30:23 +0000 (19:30 +0000)
We should lookup then in forward order, as they are sorted from
most-specific first, with parents at the end.

This breaks test, will fix in the last commit (3/3).

git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/eina@68032 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/lib/eina_model.c

index b6d3589..104f4dd 100644 (file)
@@ -3487,17 +3487,17 @@ EAPI const Eina_Model_Interface *
 eina_model_interface_get(const Eina_Model *model, const char *name)
 {
    const Eina_Model_Description *desc;
-   const Eina_Model_Interface **itr, **itr_first;
+   const Eina_Model_Interface **itr, **itr_end;
 
    EINA_MODEL_INSTANCE_CHECK_VAL(model, NULL);
    EINA_SAFETY_ON_NULL_RETURN_VAL(name, NULL);
 
    desc = model->desc;
-   itr_first = desc->cache.ifaces;
-   itr = itr_first + desc->total.ifaces - 1;
+   itr = desc->cache.ifaces;
+   itr_end = itr + desc->total.ifaces;
 
    /* fallback to strcmp if user is lazy about speed */
-   for (; itr >= itr_first; itr--)
+   for (; itr < itr_end; itr++)
      if (strcmp((*itr)->name, name) == 0)
        return *itr;