From: Garrett Regier Date: Tue, 21 Sep 2021 21:36:40 +0000 (-0700) Subject: builder: Use a GQueue in precompile X-Git-Tag: archive/raspbian/4.6.5+ds-1+rpi1~1^2~19^2~5^2~56^2~7 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=1bfd0e5e3817eaa069663984c897b3d03c1f8726;p=gtk4.git builder: Use a GQueue in precompile This avoids g_list_last() and embeds the GList link in the RecordDataTree. --- diff --git a/gtk/gtkbuilderprecompile.c b/gtk/gtkbuilderprecompile.c index 56f78476ff..00f2a796ac 100644 --- a/gtk/gtkbuilderprecompile.c +++ b/gtk/gtkbuilderprecompile.c @@ -50,7 +50,8 @@ struct RecordDataTree { int n_attributes; RecordDataString *data; RecordDataString **attributes; - GList *children; + GList link; + GQueue children; }; typedef struct { @@ -70,9 +71,10 @@ record_data_tree_new (RecordDataTree *parent, tree->parent = parent; tree->type = type; tree->data = data; + tree->link.data = tree; if (parent) - parent->children = g_list_prepend (parent->children, tree); + g_queue_push_tail_link (&parent->children, &tree->link); return tree; } @@ -80,7 +82,16 @@ record_data_tree_new (RecordDataTree *parent, static void record_data_tree_free (RecordDataTree *tree) { - g_list_free_full (tree->children, (GDestroyNotify)record_data_tree_free); + GList *l, *next; + + l = tree->children.head; + while (l) + { + next = l->next; + record_data_tree_free (l->data); + l = next; + } + g_free (tree->attributes); g_slice_free (RecordDataTree, tree); } @@ -299,7 +310,7 @@ marshal_tree (GString *marshaled, /* Special case the root */ if (tree->parent == NULL) { - for (l = g_list_last (tree->children); l != NULL; l = l->prev) + for (l = tree->children.head; l != NULL; l = l->next) marshal_tree (marshaled, l->data); return; } @@ -318,7 +329,7 @@ marshal_tree (GString *marshaled, marshal_uint32 (marshaled, attr_names[i]->offset); marshal_uint32 (marshaled, attr_values[i]->offset); } - for (l = g_list_last (tree->children); l != NULL; l = l->prev) + for (l = tree->children.head; l != NULL; l = l->next) marshal_tree (marshaled, l->data); marshal_uint32 (marshaled, RECORD_TYPE_END_ELEMENT);