cedric pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=3dcc172f5706f73c0c2d9311f246f5b43831c49b

commit 3dcc172f5706f73c0c2d9311f246f5b43831c49b
Author: Cedric BAIL <[email protected]>
Date:   Sun Jul 6 13:15:21 2014 +0200

    eo: make parent_set a O(1) operation instead of O(n).
    
    This does impact performance quite significantly when you have a lot
    of children.
---
 src/lib/eo/eo_base_class.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/lib/eo/eo_base_class.c b/src/lib/eo/eo_base_class.c
index a050585..fe9cc5f 100644
--- a/src/lib/eo/eo_base_class.c
+++ b/src/lib/eo/eo_base_class.c
@@ -16,6 +16,7 @@ typedef struct
 {
    Eina_List *children;
    Eo *parent;
+   Eina_List *parent_list;
 
    Eina_Inlist *generic_data;
    Eo ***wrefs;
@@ -115,8 +116,9 @@ _eo_base_parent_set(Eo *obj, Eo_Base_Data *pd, Eo 
*parent_id)
         old_parent_pd = eo_data_scope_get(pd->parent, EO_BASE_CLASS);
         if (old_parent_pd)
           {
-             old_parent_pd->children = 
eina_list_remove(old_parent_pd->children,
-                                                        obj);
+             old_parent_pd->children = 
eina_list_remove_list(old_parent_pd->children,
+                                                             pd->parent_list);
+             pd->parent_list = NULL;
           }
         else
           {
@@ -138,6 +140,7 @@ _eo_base_parent_set(Eo *obj, Eo_Base_Data *pd, Eo 
*parent_id)
              pd->parent = parent_id;
              parent_pd->children = eina_list_append(parent_pd->children,
                    obj);
+             pd->parent_list = eina_list_last(parent_pd->children);
              eo_xref(obj, pd->parent);
           }
         else

-- 


Reply via email to