jackdanielz pushed a commit to branch master. http://git.enlightenment.org/tools/erigo.git/commit/?id=7a573e4a4d2135d290f6935b4030be598b27beb1
commit 7a573e4a4d2135d290f6935b4030be598b27beb1 Author: Daniel Zaoui <daniel.za...@samsung.com> Date: Tue Nov 3 16:39:05 2015 +0200 ObjTree: remove hash table --- src/bin/gui/objtree.c | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/src/bin/gui/objtree.c b/src/bin/gui/objtree.c index 791fb2b..4bb1030 100644 --- a/src/bin/gui/objtree.c +++ b/src/bin/gui/objtree.c @@ -15,12 +15,11 @@ static ObjTreeViewCbs *_view_cbs = NULL; static Elm_Genlist_Item_Class *_itc = NULL; -/* Hash table from widgets to genlist items */ -static Eina_Hash *_widgets_to_items_hash_table = NULL; - /* Hash table to keep track of which items are oppened and which not */ static Eina_Hash *_openned_items_set = NULL; +#define DATA_ITEM "_objtree_item" + static const char * _objtree_filter_entry_string_get() { @@ -163,7 +162,7 @@ _item_expand(Gui_Widget *wdg, Elm_Object_Item *parent) { nitem = elm_genlist_item_append(lst, _itc, w, parent, type, _view_cbs->item_selection_cb_func, NULL); - eina_hash_set(_widgets_to_items_hash_table, wdgname, nitem); + wdg_data_set(w, DATA_ITEM, nitem); /* Expand item if it is in _opened_hash or if item meets filter condition. */ if ((eina_hash_find(_openned_items_set, wdgname)) || @@ -197,7 +196,7 @@ static void _item_del_cb(void *data, Eo *obj EINA_UNUSED) { Gui_Widget *wdg = data; - if (wdg) eina_hash_del_by_key(_widgets_to_items_hash_table, wdg_name_get(wdg)); + wdg_data_set(wdg, DATA_ITEM, NULL); } ObjTreeViewCbs *objtree_cbs_get() @@ -225,11 +224,6 @@ objtree_init() _itc->func.del = _item_del_cb; } - if (!_widgets_to_items_hash_table) - { - _widgets_to_items_hash_table = eina_hash_string_superfast_new(NULL); - } - if (!_openned_items_set) { _openned_items_set = eina_hash_string_superfast_new(NULL); @@ -247,8 +241,6 @@ objtree_shutdown() elm_genlist_clear(lst); lst = NULL; if (_itc) elm_genlist_item_class_free(_itc); - if (_widgets_to_items_hash_table) eina_hash_free(_widgets_to_items_hash_table); - _widgets_to_items_hash_table = NULL; if (_openned_items_set) eina_hash_free(_openned_items_set); _openned_items_set = NULL; } @@ -282,15 +274,14 @@ objtree_item_selected_set(const Gui_Widget *wdg) if (!wdg) return; - Eina_List *chain = eina_list_append(NULL, wdg_name_get(wdg)); + Eina_List *chain = eina_list_append(NULL, wdg); while ((wdg = wdg_parent_get(wdg))) { - chain = eina_list_prepend(chain, wdg_name_get(wdg)); + chain = eina_list_prepend(chain, wdg); } - const char *name; - EINA_LIST_FREE(chain, name) + EINA_LIST_FREE(chain, wdg) { - item = eina_hash_find(_widgets_to_items_hash_table, name); + item = wdg_data_get(wdg, DATA_ITEM); elm_genlist_item_expanded_set(item, EINA_TRUE); } elm_genlist_item_bring_in(item, ELM_GENLIST_ITEM_SCROLLTO_MIDDLE); @@ -362,8 +353,8 @@ objtree_build(const Gui_Context *ctx) void objtree_item_remove(const Gui_Widget *wdg) { - if (!_widgets_to_items_hash_table) return; - Elm_Object_Item *it = eina_hash_find(_widgets_to_items_hash_table, wdg_name_get(wdg)); + if (!wdg) return; + Elm_Object_Item *it = wdg_data_get(wdg, DATA_ITEM); if (it) elm_object_item_del(it); } --