forked from enlightenment/efl
edje/optimization: keep a style hash for fast retrival of styles
As edje mostly deals with style string. to get the style data each time it linearly search through list to find out the style which is not very cache friendly so keep a hash to do first lookup with less impact on cache. Reviewed-by: Cedric BAIL <cedric.bail@free.fr> Differential Revision: https://phab.enlightenment.org/D9547
This commit is contained in:
parent
676835458f
commit
10501b170f
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue