builder: Simplify parameter collection

This avoids setting the GValue only to toss it at the
end of the loop body. Instead, we can just do nothing
if this property isn't interesting to us.
This commit is contained in:
Matthias Clasen 2021-09-28 16:59:22 -04:00
parent f5db501879
commit e99ac8f6d8

View File

@ -539,10 +539,19 @@ gtk_builder_get_parameters (GtkBuilder *builder,
PropertyInfo *prop = g_ptr_array_index (properties, i);
const char *property_name = prop->pspec->name;
GValue property_value = G_VALUE_INIT;
ObjectProperties *params;
if (prop->applied)
continue;
if ((prop->pspec->flags & filter_flags) != 0)
params = filtered_parameters;
else
params = parameters;
if (!params)
continue;
if (prop->value)
{
g_value_init (&property_value, G_PARAM_SPEC_VALUE_TYPE (prop->pspec));
@ -616,19 +625,8 @@ gtk_builder_get_parameters (GtkBuilder *builder,
* copy it to one of the two arrays, or unset it.
*/
g_assert (G_IS_VALUE (&property_value));
if ((prop->pspec->flags & filter_flags) != 0 && filtered_parameters)
{
object_properties_add (filtered_parameters, property_name, &property_value);
prop->applied = TRUE;
}
else if ((prop->pspec->flags & filter_flags) == 0 && parameters)
{
object_properties_add (parameters, property_name, &property_value);
prop->applied = TRUE;
}
else
g_value_unset (&property_value);
object_properties_add (params, property_name, &property_value);
prop->applied = TRUE;
}
}