edje/optimization: keep a readonly flag on edje_style.
Just to check if the edje style has text_class tag we do lot of pointer hopping by linearly scan through the tags in the style which is not very cache efficient. by keeping a readonly flag we can avoid those acess if the style dosen't have any text_class tags. and if we have those tags then we can start updating the style straight away. Reviewed-by: Cedric BAIL <cedric.bail@free.fr> Differential Revision: https://phab.enlightenment.org/D9546
This commit is contained in:
parent
11d2202635
commit
d672d55107
|
@ -627,7 +627,12 @@ struct _Edje_Style
|
|||
Eina_List *tags;
|
||||
Evas_Textblock_Style *style;
|
||||
|
||||
Eina_Bool cache;
|
||||
Eina_Bool cache : 1;
|
||||
/* * read only * true if no text_class and no color_class exits in the style.
|
||||
* added for performace as we don't have to check all tags to decide if we need to update
|
||||
* this style or not.
|
||||
*/
|
||||
Eina_Bool readonly : 1;
|
||||
};
|
||||
|
||||
struct _Edje_Style_Tag
|
||||
|
|
|
@ -168,7 +168,6 @@ _edje_textblock_style_update(Edje *ed, Edje_Style *stl, Eina_Bool force)
|
|||
Eina_Strbuf *txt = NULL;
|
||||
Edje_Style_Tag *tag;
|
||||
Edje_Text_Class *tc;
|
||||
int found = 0;
|
||||
char *fontset = NULL, *fontsource = NULL;
|
||||
|
||||
if (!ed->file) return;
|
||||
|
@ -176,21 +175,12 @@ _edje_textblock_style_update(Edje *ed, Edje_Style *stl, Eina_Bool force)
|
|||
/* Make sure the style is already defined */
|
||||
if (!stl->style) return;
|
||||
|
||||
/* we are sure it dosen't have any text_class */
|
||||
if (stl->readonly) return;
|
||||
|
||||
/* No need to compute it again and again and again */
|
||||
if (!force && stl->cache) return;
|
||||
|
||||
/* Make sure the style contains a text_class */
|
||||
EINA_LIST_FOREACH(stl->tags, l, tag)
|
||||
{
|
||||
if (tag->text_class)
|
||||
{
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* No text classes , goto next style */
|
||||
if (!found) return;
|
||||
if (!txt)
|
||||
txt = eina_strbuf_new();
|
||||
|
||||
|
@ -430,7 +420,8 @@ _edje_textblock_styles_cache_free(Edje *ed, const char *text_class)
|
|||
EINA_LIST_FOREACH(ed->file->styles, l, stl)
|
||||
{
|
||||
Edje_Style_Tag *tag;
|
||||
Eina_Bool found = EINA_FALSE;
|
||||
|
||||
if (stl->readonly) continue;
|
||||
|
||||
EINA_LIST_FOREACH(stl->tags, ll, tag)
|
||||
{
|
||||
|
@ -438,12 +429,10 @@ _edje_textblock_styles_cache_free(Edje *ed, const char *text_class)
|
|||
|
||||
if (!strcmp(tag->text_class, text_class))
|
||||
{
|
||||
found = EINA_TRUE;
|
||||
stl->cache = EINA_FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (found)
|
||||
stl->cache = EINA_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -467,6 +456,8 @@ _edje_textblock_style_parse_and_fix(Edje_File *edf)
|
|||
|
||||
if (stl->style) break;
|
||||
|
||||
stl->readonly = EINA_TRUE;
|
||||
|
||||
if (!txt)
|
||||
txt = eina_strbuf_new();
|
||||
|
||||
|
@ -516,6 +507,8 @@ _edje_textblock_style_parse_and_fix(Edje_File *edf)
|
|||
}
|
||||
}
|
||||
eina_strbuf_append(txt, "'");
|
||||
|
||||
if (tag->text_class) stl->readonly = EINA_FALSE;
|
||||
}
|
||||
if (fontset) free(fontset);
|
||||
if (fontsource) free(fontsource);
|
||||
|
|
Loading…
Reference in New Issue