From a880a756cd8e904f32ce2048f8dce7b63f90bebb Mon Sep 17 00:00:00 2001 From: subhransu mohanty Date: Mon, 19 Aug 2019 19:33:56 +0900 Subject: [PATCH] edje/styles: avoid redundant style tag addition by providing extra checks. Summary: we should only add font_size tag if the new size is different. we should only add font tag if there is a new font. Reviewers: ali.alzyod, Hermet, cedric, raster Reviewed By: Hermet Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D9613 --- src/lib/edje/edje_textblock_styles.c | 36 +++++++++++----------------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/src/lib/edje/edje_textblock_styles.c b/src/lib/edje/edje_textblock_styles.c index cebbd23677..efe4520921 100644 --- a/src/lib/edje/edje_textblock_styles.c +++ b/src/lib/edje/edje_textblock_styles.c @@ -208,44 +208,36 @@ _edje_textblock_style_update(Edje *ed, Edje_Style *stl, Eina_Bool force) { if (fontset) { - eina_strbuf_append(txt, " "); - eina_strbuf_append(txt, "font_fallbacks="); + eina_strbuf_append(txt, " font_fallbacks="); eina_strbuf_append(txt, fontset); } if (fontsource) { - eina_strbuf_append(txt, " "); - eina_strbuf_append(txt, "font_source="); + eina_strbuf_append(txt, " font_source="); eina_strbuf_append(txt, fontsource); } } - if (!EINA_DBL_EQ(tag->font_size, 0)) + if (tc && tc->size && !EINA_DBL_EQ(tag->font_size, 0)) { - char font_size[32]; + double new_size = _edje_text_size_calc(tag->font_size, tc); + if (!EINA_DBL_EQ(tag->font_size, new_size)) + { + char buffer[32]; - if (tc && tc->size) - snprintf(font_size, sizeof(font_size), "%f", - (double)_edje_text_size_calc(tag->font_size, tc)); - else - snprintf(font_size, sizeof(font_size), "%f", - tag->font_size); - - eina_strbuf_append(txt, " "); - eina_strbuf_append(txt, "font_size="); - eina_strbuf_append(txt, font_size); + snprintf(buffer, sizeof(buffer), "%.1f", new_size); + eina_strbuf_append(txt, " font_size="); + eina_strbuf_append(txt, buffer); + } } /* Add font name last to save evas from multiple loads */ - if (tag->font) + if (tc && tc->font && tag->font) { const char *f; char *sfont = NULL; - eina_strbuf_append(txt, " "); - eina_strbuf_append(txt, "font="); - - if (tc) f = _edje_text_font_get(tag->font, tc->font, &sfont); - else f = tag->font; + eina_strbuf_append(txt, " font="); + f = _edje_text_font_get(tag->font, tc->font, &sfont); eina_strbuf_append_escaped(txt, f); if (sfont) free(sfont);