Enlightenment CVS committal

Author  : ningerso
Project : e17
Module  : libs/evas

Dir     : e17/libs/evas/src/lib/canvas


Modified Files:
        evas_object_textblock.c 


Log Message:
Reduce additional layout parsing overhead by using the format string without
copying the contents to temporary buffers. This cuts the time spent during
the layout phase in half.

===================================================================
RCS file: /cvs/e/e17/libs/evas/src/lib/canvas/evas_object_textblock.c,v
retrieving revision 1.133
retrieving revision 1.134
diff -u -3 -r1.133 -r1.134
--- evas_object_textblock.c     28 Nov 2006 16:14:11 -0000      1.133
+++ evas_object_textblock.c     28 Nov 2006 20:30:48 -0000      1.134
@@ -874,10 +874,29 @@
 }
 
 static void
+_format_clean_param(char *dst, const char *src)
+{
+   const char *ss;
+   char *ds;
+
+   ds = dst;
+   for (ss = src; *ss; ss++, ds++)
+     {
+        if ((*ss == '\\') && *(ss + 1)) ss++;
+        *ds = *ss;
+     }
+   *ds = 0;
+}
+
+static void
 _format_command(Evas_Object *obj, Evas_Object_Textblock_Format *fmt, const 
char *cmd, const char *param)
 {
    int new_font = 0;
+   char *tmp_param;
+
+   tmp_param = alloca(strlen(param) + 1);
    
+   _format_clean_param(tmp_param, param);
    if (cmd == fontstr)
      {
        if ((!fmt->font.name) ||
@@ -1162,7 +1181,7 @@
 static char *
 _format_parse(char **s)
 {
-   char *p, *item, *ss, *ds;
+   char *p, *item;
    char *s1 = NULL, *s2 = NULL;
    
    p = *s;
@@ -1185,17 +1204,8 @@
        p++;
        if (s1 && s2)
          {
-            item = malloc(s2 - s1 + 1);
-            if (item)
-              {
-                 ds = item;
-                 for (ss = s1; ss < s2; ss++, ds++)
-                   {
-                      if ((*ss == '\\') && (ss < (s2 - 1))) ss++;
-                      *ds = *ss;
-                   }
-                 *ds = 0;
-              }
+            item = s1;
+
             *s = s2;
             return item;
          }
@@ -1217,6 +1227,8 @@
 
    while ((item = _format_parse(&s)))
      {
+       char tmp_delim = *s;
+       *s = '\0';
        if (_format_is_param(item))
          {
             const char *key = NULL, *val = NULL;
@@ -1230,7 +1242,7 @@
          {
             /* immediate - not handled here */
          }
-       free(item);
+       *s = tmp_delim;
      }
 }
 
@@ -1993,6 +2005,8 @@
               }
             while ((item = _format_parse(&s)))
               {
+                 char tmp_delim = *s;
+                 *s = '\0';
                  if (_format_is_param(item))
                    _layout_format_value_handle(c, fmt, item);
                  else
@@ -2034,7 +2048,7 @@
                            c->x = x2;
                         }
                    }
-                 free(item);
+                 *s = tmp_delim;
               }
 
             evas_text_style_pad_get(fmt->style, &style_pad_l, &style_pad_r, 
&style_pad_t, &style_pad_b);



-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to