[gtk+] stylepropertis: Use set_by_property() in set_valist()



commit 70e654f1a5b8ec7ac86012cb9910c7ebbc6da849
Author: Benjamin Otte <otte redhat com>
Date:   Sat May 21 21:19:57 2011 +0200

    stylepropertis: Use set_by_property() in set_valist()
    
    ... instead of duplicating code. This causes an extra g_value_copy().
    If that turns out to be a performance issue, we can invent something
    that handles this (like passing a gboolean take_value).
    
    The reason for this duplication deletion is that we want to complicate
    the setting code to handle shorthands by unpacking them and storing the
    separate values.

 gtk/gtkstyleproperties.c |   24 ++++++------------------
 1 files changed, 6 insertions(+), 18 deletions(-)
---
diff --git a/gtk/gtkstyleproperties.c b/gtk/gtkstyleproperties.c
index 946347f..1c5f0d9 100644
--- a/gtk/gtkstyleproperties.c
+++ b/gtk/gtkstyleproperties.c
@@ -600,9 +600,8 @@ gtk_style_properties_set_valist (GtkStyleProperties *props,
   while (property_name)
     {
       const GtkStyleProperty *node;
-      PropertyData *prop;
       gchar *error = NULL;
-      GValue *val;
+      GValue val;
 
       node = _gtk_style_property_lookup (property_name);
 
@@ -612,30 +611,19 @@ gtk_style_properties_set_valist (GtkStyleProperties *props,
           break;
         }
 
-      prop = g_hash_table_lookup (priv->properties, node->pspec);
-
-      if (!prop)
-        {
-          prop = property_data_new ();
-          g_hash_table_insert (priv->properties, node->pspec, prop);
-        }
-
-      val = property_data_get_value (prop, state);
-
-      if (G_IS_VALUE (val))
-        g_value_unset (val);
-
-      G_VALUE_COLLECT_INIT (val, node->pspec->value_type,
+      G_VALUE_COLLECT_INIT (&val, node->pspec->value_type,
                             args, 0, &error);
-      g_param_value_validate (node->pspec, val);
       if (error)
         {
           g_warning ("Could not set style property \"%s\": %s", property_name, error);
-          g_value_unset (val);
+          g_value_unset (&val);
           g_free (error);
           break;
         }
 
+      _gtk_style_properties_set_property_by_property (props, node, state, &val);
+      g_value_unset (&val);
+
       property_name = va_arg (args, const gchar *);
     }
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]