edje: improve speed when deleting text member class.
authorcedric <cedric@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Tue, 31 May 2011 16:51:48 +0000 (16:51 +0000)
committercedric <cedric@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Tue, 31 May 2011 16:51:48 +0000 (16:51 +0000)
git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/edje@59850 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

ChangeLog
src/lib/edje_main.c
src/lib/edje_private.h
src/lib/edje_util.c

index deb1382..c75af5f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
         evas freeze and thaw calls. May help in certain pathological
         situations.
 
+2011-05-27  Cedric Bail
+
+       * Improve performance by avoiding walking eina_list for nothing
+       when deleting member_class.
index 2aebe07..f802ec1 100644 (file)
@@ -221,6 +221,8 @@ _edje_del(Edje *ed)
         eina_stringshare_del(cb->part);
         free(cb);
      }
+
+   eina_hash_free(ed->members);
    free(ed);
 }
 
index 2bd70e9..d2503a8 100644 (file)
@@ -1004,6 +1004,8 @@ struct _Edje
    int                   table_programs_size;
    unsigned int          table_parts_size;
 
+   Eina_Hash            *members;
+
    Edje_Perspective     *persp;
 
    struct {
index f28afa7..8d1a392 100644 (file)
@@ -3674,33 +3674,38 @@ _edje_text_class_member_add(Edje *ed, const char *text_class)
    /* Get members list */
    members = eina_hash_find(_edje_text_class_member_hash, text_class);
 
-   /* Remove members list */
-   if (members)
-     eina_hash_del(_edje_text_class_member_hash, text_class, members);
-
    /* Update the member list */
    members = eina_list_prepend(members, ed);
 
-   /* Add the member list back */
+   /* Don't loose track of members list */
+   if (!ed->members)
+     ed->members = eina_hash_string_small_new(NULL);
+   eina_hash_set(ed->members, text_class, members);
+
+   /* Reset the member list to the right pointer */
    if (!_edje_text_class_member_hash)
      _edje_text_class_member_hash = eina_hash_string_superfast_new(NULL);
-   eina_hash_add(_edje_text_class_member_hash, text_class, members);
+   eina_hash_set(_edje_text_class_member_hash, text_class, members);
 }
 
 void
 _edje_text_class_member_del(Edje *ed, const char *text_class)
 {
    Eina_List *members;
+   Eina_List *lookup;
 
    if ((!ed) || (!text_class)) return;
    members = eina_hash_find(_edje_text_class_member_hash, text_class);
    if (!members) return;
 
-   eina_hash_del(_edje_text_class_member_hash, text_class, members);
+   lookup = eina_hash_find(ed->members, text_class);
 
-   members = eina_list_remove(members, ed);
-   if (members)
-     eina_hash_add(_edje_text_class_member_hash, text_class, members);
+   if (!lookup) return ;
+
+   eina_hash_del(ed->members, text_class, lookup);
+   members = eina_list_remove_list(members, lookup);
+
+   eina_hash_set(_edje_text_class_member_hash, text_class, members);
 }
 
 void