hermet pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=a880a756cd8e904f32ce2048f8dce7b63f90bebb

commit a880a756cd8e904f32ce2048f8dce7b63f90bebb
Author: subhransu mohanty <sub.moha...@samsung.com>
Date:   Mon Aug 19 19:33:56 2019 +0900

    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 | 38 ++++++++++++++----------------------
 1 file changed, 15 insertions(+), 23 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];
-
-             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);
+             double new_size = _edje_text_size_calc(tag->font_size, tc);
+             if (!EINA_DBL_EQ(tag->font_size, new_size))
+               {
+                  char buffer[32];
+
+                  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);

-- 


Reply via email to