[gtk/matthiasc/for-master: 1/2] builder: Simplify parameter collection
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/matthiasc/for-master: 1/2] builder: Simplify parameter collection
- Date: Tue, 28 Sep 2021 21:49:23 +0000 (UTC)
commit e99ac8f6d831a3fccaffd255bf229a5efe633870
Author: Matthias Clasen <mclasen redhat com>
Date: Tue Sep 28 16:59:22 2021 -0400
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.
gtk/gtkbuilder.c | 24 +++++++++++-------------
1 file changed, 11 insertions(+), 13 deletions(-)
---
diff --git a/gtk/gtkbuilder.c b/gtk/gtkbuilder.c
index fef468e8bb..ed90fd7b99 100644
--- a/gtk/gtkbuilder.c
+++ b/gtk/gtkbuilder.c
@@ -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;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]