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)
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
627 Eina_List *tags; 627 Eina_List *tags;
628 Evas_Textblock_Style *style; 628 Evas_Textblock_Style *style;
629 629
630 Eina_Bool cache; 630 Eina_Bool cache : 1;
631 /* * read only * true if no text_class and no color_class exits in the style.
632 * added for performace as we don't have to check all tags to decide if we need to update
633 * this style or not.
634 */
635 Eina_Bool readonly : 1;
631}; 636};
632 637
633struct _Edje_Style_Tag 638struct _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)
168 Eina_Strbuf *txt = NULL; 168 Eina_Strbuf *txt = NULL;
169 Edje_Style_Tag *tag; 169 Edje_Style_Tag *tag;
170 Edje_Text_Class *tc; 170 Edje_Text_Class *tc;
171 int found = 0;
172 char *fontset = NULL, *fontsource = NULL; 171 char *fontset = NULL, *fontsource = NULL;
173 172
174 if (!ed->file) return; 173 if (!ed->file) return;
@@ -176,21 +175,12 @@ _edje_textblock_style_update(Edje *ed, Edje_Style *stl, Eina_Bool force)
176 /* Make sure the style is already defined */ 175 /* Make sure the style is already defined */
177 if (!stl->style) return; 176 if (!stl->style) return;
178 177
178 /* we are sure it dosen't have any text_class */
179 if (stl->readonly) return;
180
179 /* No need to compute it again and again and again */ 181 /* No need to compute it again and again and again */
180 if (!force && stl->cache) return; 182 if (!force && stl->cache) return;
181 183
182 /* Make sure the style contains a text_class */
183 EINA_LIST_FOREACH(stl->tags, l, tag)
184 {
185 if (tag->text_class)
186 {
187 found = 1;
188 break;
189 }
190 }
191
192 /* No text classes , goto next style */
193 if (!found) return;
194 if (!txt) 184 if (!txt)
195 txt = eina_strbuf_new(); 185 txt = eina_strbuf_new();
196 186
@@ -430,7 +420,8 @@ _edje_textblock_styles_cache_free(Edje *ed, const char *text_class)
430 EINA_LIST_FOREACH(ed->file->styles, l, stl) 420 EINA_LIST_FOREACH(ed->file->styles, l, stl)
431 { 421 {
432 Edje_Style_Tag *tag; 422 Edje_Style_Tag *tag;
433 Eina_Bool found = EINA_FALSE; 423
424 if (stl->readonly) continue;
434 425
435 EINA_LIST_FOREACH(stl->tags, ll, tag) 426 EINA_LIST_FOREACH(stl->tags, ll, tag)
436 { 427 {
@@ -438,12 +429,10 @@ _edje_textblock_styles_cache_free(Edje *ed, const char *text_class)
438 429
439 if (!strcmp(tag->text_class, text_class)) 430 if (!strcmp(tag->text_class, text_class))
440 { 431 {
441 found = EINA_TRUE; 432 stl->cache = EINA_FALSE;
442 break; 433 break;
443 } 434 }
444 } 435 }
445 if (found)
446 stl->cache = EINA_FALSE;
447 } 436 }
448} 437}
449 438
@@ -467,6 +456,8 @@ _edje_textblock_style_parse_and_fix(Edje_File *edf)
467 456
468 if (stl->style) break; 457 if (stl->style) break;
469 458
459 stl->readonly = EINA_TRUE;
460
470 if (!txt) 461 if (!txt)
471 txt = eina_strbuf_new(); 462 txt = eina_strbuf_new();
472 463
@@ -516,6 +507,8 @@ _edje_textblock_style_parse_and_fix(Edje_File *edf)
516 } 507 }
517 } 508 }
518 eina_strbuf_append(txt, "'"); 509 eina_strbuf_append(txt, "'");
510
511 if (tag->text_class) stl->readonly = EINA_FALSE;
519 } 512 }
520 if (fontset) free(fontset); 513 if (fontset) free(fontset);
521 if (fontsource) free(fontsource); 514 if (fontsource) free(fontsource);