summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsubhransu mohanty <sub.mohanty@samsung.com>2019-08-13 03:11:30 +0000
committerCedric BAIL <cedric.bail@free.fr>2019-08-14 12:08:17 -0700
commitd672d55107efba803c928a55252ab00afe2d0ba3 (patch)
tree6794bfd8f0a90920394c5faa5a7fe8a7cbc7f4e1
parent11d2202635587785baaa7276b1129d115d52f2ea (diff)
downloadefl-d672d55107efba803c928a55252ab00afe2d0ba3.tar.gz
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
-rw-r--r--src/lib/edje/edje_private.h7
-rw-r--r--src/lib/edje/edje_textblock_styles.c27
2 files changed, 16 insertions, 18 deletions
diff --git a/src/lib/edje/edje_private.h b/src/lib/edje/edje_private.h
index 15145aeaa1..0eab189859 100644
--- a/src/lib/edje/edje_private.h
+++ b/src/lib/edje/edje_private.h
@@ -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
diff --git a/src/lib/edje/edje_textblock_styles.c b/src/lib/edje/edje_textblock_styles.c
index e83a21d227..555cab92c0 100644
--- a/src/lib/edje/edje_textblock_styles.c
+++ b/src/lib/edje/edje_textblock_styles.c
@@ -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);