[glib/gobject-speedups: 16/28] Simplify g_object_new_with_properties




commit 2ef05fe980aff7cde8c9fe2ad8ddab91ec730992
Author: Matthias Clasen <mclasen redhat com>
Date:   Wed Sep 29 00:18:51 2021 -0400

    Simplify g_object_new_with_properties
    
    This was doing an unnecessary extra copy of
    the GValues. We can avoid that.

 gobject/gobject.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)
---
diff --git a/gobject/gobject.c b/gobject/gobject.c
index a912a5f2a1..b4b818b083 100644
--- a/gobject/gobject.c
+++ b/gobject/gobject.c
@@ -2173,18 +2173,10 @@ g_object_new_with_properties (GType          object_type,
           if (!g_object_new_is_valid_property (object_type, pspec, names[i], params, count))
             continue;
           params[count].pspec = pspec;
-
-          /* Init GValue */
-          params[count].value = g_newa0 (GValue, 1);
-          g_value_init (params[count].value, G_VALUE_TYPE (&values[i]));
-
-          g_value_copy (&values[i], params[count].value);
+          params[count].value = (GValue *)&values[i];
           count++;
         }
       object = g_object_new_internal (class, params, count);
-
-      while (count--)
-        g_value_unset (params[count].value);
     }
   else
     object = g_object_new_internal (class, NULL, 0);


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