[gtk/optimize-precompile: 6/11] builder: Use a GQueue in precompile
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/optimize-precompile: 6/11] builder: Use a GQueue in precompile
- Date: Fri, 10 Dec 2021 19:48:08 +0000 (UTC)
commit a8837476669579dfa8dce9322eaddd30daaf0531
Author: Garrett Regier <garrettregier gmail com>
Date: Tue Sep 21 14:36:40 2021 -0700
builder: Use a GQueue in precompile
This avoids g_list_last() and
embeds the GList link in the RecordDataTree.
gtk/gtkbuilderprecompile.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
---
diff --git a/gtk/gtkbuilderprecompile.c b/gtk/gtkbuilderprecompile.c
index 72a8d9f8c7..ba9f593c63 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,11 @@ 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;
+
+ for (l = tree->children.head; l != NULL; l = l->next)
+ record_data_tree_free (l->data);
+
g_free (tree->attributes);
g_slice_free (RecordDataTree, tree);
}
@@ -299,7 +305,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 +324,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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]