g_object_new(): skip varargs for simple calls
authorKamal Mostafa <kamal@whence.com>
Sat, 2 Jan 2010 04:36:28 +0000 (20:36 -0800)
committerBenjamin Otte <otte@gnome.org>
Mon, 11 Jan 2010 14:34:41 +0000 (15:34 +0100)
g_object_new() avoids useless varargs processing for simple calls with no
properties.  Fixes https://bugzilla.gnome.org/show_bug.cgi?id=605883

gobject/gobject.c

index 58554c3372a41e197c3a0889888daa5d04b85a3f..bd631524066fc6402a63a555e79b3a064a86448b 100644 (file)
@@ -1087,6 +1087,10 @@ g_object_new (GType         object_type,
   
   g_return_val_if_fail (G_TYPE_IS_OBJECT (object_type), NULL);
   
+  /* short circuit for calls supplying no properties */
+  if (!first_property_name)
+    return g_object_newv (object_type, 0, NULL);
+
   va_start (var_args, first_property_name);
   object = g_object_new_valist (object_type, first_property_name, var_args);
   va_end (var_args);