Conditionally use G_VALUE_COLLECT_INIT() macro

GLib 2.24 (but starting from the 2.23.2 unstable release) added a new
macro for collecting GValues from a va_list.

The newly added G_VALUE_COLLECT_INIT() macro should be used in place
of initializing the GValue and calling G_VALUE_COLLECT(), and improves
the collection performances by avoiding multiple checks, free and
initialization calls.
This commit is contained in:
Emmanuele Bassi 2010-02-25 10:22:36 +00:00
parent bd303d6efb
commit 26e22b2ede
6 changed files with 45 additions and 1 deletions

View File

@ -1837,8 +1837,16 @@ clutter_animation_setup_valist (ClutterAnimation *animation,
break;
}
#if GLIB_CHECK_VERSION (2, 23, 2)
G_VALUE_COLLECT_INIT (&file, G_PARAM_SPEC_VALUE_TYPE (pspec),
var_args, 0,
&error);
#else
/* this is the same as G_VALUE_COLLECT_INIT(), but slower */
g_value_init (&final, G_PARAM_SPEC_VALUE_TYPE (pspec));
G_VALUE_COLLECT (&final, var_args, 0, &error);
#endif /* GLIB_CHECK_VERSION (2, 23, 2) */
if (error)
{
g_warning ("%s: %s", G_STRLOC, error);

View File

@ -961,9 +961,14 @@ clutter_animator_set (ClutterAnimator *animator,
break;
}
/* FIXME - Depend on GLib 2.24 and use G_VALUE_COLLECT_INIT() */
#if GLIB_CHECK_VERSION (2, 23, 2)
G_VALUE_COLLECT_INIT (&value, G_PARAM_SPEC_VALUE_TYPE (pspec),
args, 0,
&error);
#else
g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (pspec));
G_VALUE_COLLECT (&value, args, 0, &error);
#endif /* GLIB_CHECK_VERSION (2, 23, 2) */
if (error)
{

View File

@ -726,8 +726,15 @@ clutter_box_set_property_valist (ClutterBox *box,
break;
}
#if GLIB_CHECK_VERSION (2, 23, 2)
G_VALUE_COLLECT_INIT (&value, G_PARAM_SPEC_VALUE_TYPE (pspec),
var_args, 0,
&error);
#else
g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (pspec));
G_VALUE_COLLECT (&value, var_args, 0, &error);
#endif /* GLIB_CHECK_VERSION (2, 23, 2) */
if (error)
{
g_warning ("%s: %s", G_STRLOC, error);

View File

@ -1019,8 +1019,15 @@ clutter_container_child_set (ClutterContainer *container,
break;
}
#if GLIB_CHECK_VERSION (2, 23, 2)
G_VALUE_COLLECT_INIT (&value, G_PARAM_SPEC_VALUE_TYPE (pspec),
var_args, 0,
&error);
#else
g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (pspec));
G_VALUE_COLLECT (&value, var_args, 0, &error);
#endif /* GLIB_CHECK_VERSION (2, 23, 2) */
if (error)
{
/* we intentionally leak the GValue because it might

View File

@ -422,8 +422,13 @@ clutter_interval_set_interval_valist (ClutterInterval *interval,
gchar *error;
/* initial value */
#if GLIB_CHECK_VERSION (2, 23, 2)
G_VALUE_COLLECT_INIT (&value, gtype, var_args, 0, &error);
#else
g_value_init (&value, gtype);
G_VALUE_COLLECT (&value, var_args, 0, &error);
#endif /* GLIB_CHECK_VERSION (2, 23, 2) */
if (error)
{
g_warning ("%s: %s", G_STRLOC, error);
@ -440,8 +445,13 @@ clutter_interval_set_interval_valist (ClutterInterval *interval,
g_value_unset (&value);
/* final value */
#if GLIB_CHECK_VERSION (2, 23, 2)
G_VALUE_COLLECT_INIT (&value, gtype, var_args, 0, &error);
#else
g_value_init (&value, gtype);
G_VALUE_COLLECT (&value, var_args, 0, &error);
#endif /* GLIB_CHECK_VERSION (2, 23, 2) */
if (error)
{
g_warning ("%s: %s", G_STRLOC, error);

View File

@ -871,8 +871,15 @@ clutter_layout_manager_child_set (ClutterLayoutManager *manager,
break;
}
#if GLIB_CHECK_VERSION (2, 23, 2)
G_VALUE_COLLECT_INIT (&value, G_PARAM_SPEC_VALUE_TYPE (pspec),
var_args, 0,
&error);
#else
g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (pspec));
G_VALUE_COLLECT (&value, var_args, 0, &error);
#endif /* GLIB_CHECK_VERSION (2, 23, 2) */
if (error)
{
g_warning ("%s: %s", G_STRLOC, error);