diff --git a/src/lib/edje/edje_cache.c b/src/lib/edje/edje_cache.c index 97d82ba58d..c1d39f7543 100644 --- a/src/lib/edje/edje_cache.c +++ b/src/lib/edje/edje_cache.c @@ -300,6 +300,7 @@ _edje_file_open(const Eina_File *f, int *error_ret, time_t mtime, Eina_Bool coll Edje_Color_Class *cc; Edje_Text_Class *tc; Edje_Size_Class *sc; + Edje_Style *stl; Edje_File *edf; Eina_List *l, *ll; Eet_File *ef; @@ -376,6 +377,11 @@ _edje_file_open(const Eina_File *f, int *error_ret, time_t mtime, Eina_Bool coll /* This should be done at edje generation time */ _edje_textblock_style_parse_and_fix(edf); + edf->style_hash = eina_hash_string_small_new(NULL); + EINA_LIST_FOREACH(edf->styles, l, stl) + if (stl->name) + eina_hash_direct_add(edf->style_hash, stl->name, stl); + edf->color_tree_hash = eina_hash_string_small_new(NULL); EINA_LIST_FOREACH(edf->color_tree, l, ctn) EINA_LIST_FOREACH(ctn->color_classes, ll, name) diff --git a/src/lib/edje/edje_load.c b/src/lib/edje/edje_load.c index c28bfc572c..e831c7598a 100644 --- a/src/lib/edje/edje_load.c +++ b/src/lib/edje/edje_load.c @@ -2361,6 +2361,7 @@ _edje_file_free(Edje_File *edf) if (edf->path) eina_stringshare_del(edf->path); if (edf->free_strings && edf->compiler) eina_stringshare_del(edf->compiler); if (edf->free_strings) eina_stringshare_del(edf->id); + eina_hash_free(edf->style_hash); _edje_textblock_style_cleanup(edf); if (edf->ef) eet_close(edf->ef); if (edf->f) eina_file_close(edf->f); diff --git a/src/lib/edje/edje_private.h b/src/lib/edje/edje_private.h index 44dd3fe34c..75a38c1aef 100644 --- a/src/lib/edje/edje_private.h +++ b/src/lib/edje/edje_private.h @@ -572,6 +572,7 @@ struct _Edje_File unsigned int requires_count; Eina_List *styles; + Eina_Hash *style_hash; Eina_List *color_tree; Eina_Hash *color_tree_hash; diff --git a/src/lib/edje/edje_textblock_styles.c b/src/lib/edje/edje_textblock_styles.c index aee7f708b7..cb4a9c3a7a 100644 --- a/src/lib/edje/edje_textblock_styles.c +++ b/src/lib/edje/edje_textblock_styles.c @@ -240,19 +240,9 @@ _edje_textblock_style_all_update(Edje *ed) static inline Edje_Style * _edje_textblock_style_search(Edje *ed, const char *style) { - Edje_Style *stl = NULL; - Eina_List *l; - if (!style) return NULL; - EINA_LIST_FOREACH(ed->file->styles, l, stl) - { - if ((stl->name) && - (stl->name == style || !strcmp(stl->name, style))) break; - stl = NULL; - } - - return stl; + return eina_hash_find(ed->file->style_hash, style); } static inline void @@ -316,16 +306,9 @@ _edje_textblock_styles_del(Edje *ed, Edje_Part *pt) desc = (Edje_Part_Description_Text *)pt->default_desc; style = edje_string_get(&desc->text.style); - if (style) - { - Eina_List *l; - EINA_LIST_FOREACH(ed->file->styles, l, stl) - { - if ((stl->name) && (!strcmp(stl->name, style))) break; - stl = NULL; - } - } + stl = _edje_textblock_style_search(ed, style); + if (stl) { Edje_Style_Tag *tag; @@ -342,16 +325,7 @@ _edje_textblock_styles_del(Edje *ed, Edje_Part *pt) { desc = (Edje_Part_Description_Text *)pt->other.desc[i]; style = edje_string_get(&desc->text.style); - if (style) - { - Eina_List *l; - - EINA_LIST_FOREACH(ed->file->styles, l, stl) - { - if ((stl->name) && (!strcmp(stl->name, style))) break; - stl = NULL; - } - } + stl = _edje_textblock_style_search(ed, style); if (stl) { Edje_Style_Tag *tag;