From c44569c65191365add51382e68635ed82dfa02a3 Mon Sep 17 00:00:00 2001 From: cedric Date: Mon, 6 Jun 2011 17:47:32 +0000 Subject: [PATCH] edje: trying to add back my small improvements. git-svn-id: http://svn.enlightenment.org/svn/e/trunk/edje@59999 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- ChangeLog | 4 ++++ src/lib/edje_main.c | 2 ++ src/lib/edje_private.h | 2 ++ src/lib/edje_util.c | 37 ++++++++++++++++++++----------------- 4 files changed, 28 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index deb1382..c75af5f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -110,3 +110,7 @@ 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. diff --git a/src/lib/edje_main.c b/src/lib/edje_main.c index 92d255d..0b98c1a 100644 --- a/src/lib/edje_main.c +++ b/src/lib/edje_main.c @@ -200,6 +200,8 @@ _edje_del(Edje *ed) eina_stringshare_del(cb->part); free(cb); } + + if (ed->members) eina_hash_free(ed->members); free(ed); } diff --git a/src/lib/edje_private.h b/src/lib/edje_private.h index 77381e2..47a5f71 100644 --- a/src/lib/edje_private.h +++ b/src/lib/edje_private.h @@ -1007,6 +1007,8 @@ struct _Edje int table_programs_size; unsigned int table_parts_size; + Eina_Hash *members; + Edje_Perspective *persp; struct { diff --git a/src/lib/edje_util.c b/src/lib/edje_util.c index f28afa7..3ee0de8 100644 --- a/src/lib/edje_util.c +++ b/src/lib/edje_util.c @@ -3575,13 +3575,11 @@ _edje_color_class_member_add(Edje *ed, const char *color_class) Eina_List *members; if ((!ed) || (!color_class)) return; + if (!_edje_color_class_member_hash) _edje_color_class_member_hash = eina_hash_string_superfast_new(NULL); members = eina_hash_find(_edje_color_class_member_hash, color_class); - if (members) - eina_hash_del(_edje_color_class_member_hash, color_class, members); members = eina_list_prepend(members, ed); - if (!_edje_color_class_member_hash) _edje_color_class_member_hash = eina_hash_string_superfast_new(NULL); - eina_hash_add(_edje_color_class_member_hash, color_class, members); + eina_hash_set(_edje_color_class_member_hash, color_class, members); } void @@ -3590,13 +3588,13 @@ _edje_color_class_member_del(Edje *ed, const char *color_class) Eina_List *members; if ((!ed) || (!color_class)) return; + if (!_edje_color_class_member_hash) return; + members = eina_hash_find(_edje_color_class_member_hash, color_class); if (!members) return; - eina_hash_del(_edje_color_class_member_hash, color_class, members); members = eina_list_remove(members, ed); - if (members) - eina_hash_add(_edje_color_class_member_hash, color_class, members); + eina_hash_set(_edje_color_class_member_hash, color_class, members); } /** @@ -3674,33 +3672,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 -- 2.7.4