[Xfce4-commits] <midori:master> Perform fewer string allocations preparing shortcuts

Christian Dywan noreply at xfce.org
Fri May 6 03:08:02 CEST 2011


Updating branch refs/heads/master
         to 9ff5114b76cb70b603389fe1aecae724e56c4ca0 (commit)
       from 023c64fa97c35cebabc011d4f3b117e6aaf1b93e (commit)

commit 9ff5114b76cb70b603389fe1aecae724e56c4ca0
Author: Christian Dywan <christian at twotoasts.de>
Date:   Fri May 6 01:55:39 2011 +0200

    Perform fewer string allocations preparing shortcuts

 midori/midori-view.c |   18 ++++++++----------
 1 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/midori/midori-view.c b/midori/midori-view.c
index 9c8db2c..f18c6d1 100644
--- a/midori/midori-view.c
+++ b/midori/midori-view.c
@@ -3991,22 +3991,21 @@ prepare_speed_dial_html (MidoriView* view)
 
     while (slot <= rows * cols)
     {
-        gchar* position;
         gchar* dial_entry = g_strdup_printf ("Dial %d", slot);
+        gchar* uri = g_key_file_get_string (key_file, dial_entry, "uri", NULL);
+        const gchar* position;
         if (slot < cols)
-            position = g_strdup (" top");
+            position = " top";
         else if (slot == cols)
-            position = g_strdup (" top right");
+            position = " top right";
         else if (slot > cols && slot % cols == 0)
-            position = g_strdup (" right");
+            position = " right";
         else
-            position = g_strdup ("");
+            position = "";
 
-        if (g_key_file_has_group (key_file, dial_entry)
-        && g_strcmp0 (g_key_file_get_string (key_file, dial_entry, "uri", NULL), "#"))
+        if (uri && *uri && *uri != '#')
         {
             gchar* slot_id = g_strdup_printf ("s%d", slot);
-            gchar* uri = g_key_file_get_string (key_file, dial_entry, "uri", NULL);
             gchar* title = g_key_file_get_string (key_file, dial_entry, "title", NULL);
             gchar* thumb_file = sokoke_build_thumbnail_path (uri);
             gchar* encoded;
@@ -4035,7 +4034,6 @@ prepare_speed_dial_html (MidoriView* view)
                     "‪%s</p></div>\n",
                     position, slot, slot, uri, encoded, slot, title);
 
-            g_free (uri);
             g_free (title);
             g_free (encoded);
         }
@@ -4051,8 +4049,8 @@ prepare_speed_dial_html (MidoriView* view)
         }
 
         slot++;
-        g_free (position);
         g_free (dial_entry);
+        g_free (uri);
     }
     g_string_append_printf (markup,
             "</div>\n</div>\n</body>\n</html>\n");



More information about the Xfce4-commits mailing list