summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2016-11-10 19:06:52 +0000
committerRichard Hughes <richard@hughsie.com>2016-11-10 19:50:41 +0000
commit70dd12823ed224f52e0777f4217870060b8a2394 (patch)
tree6334748002330c890b583faa5123e4f943130265
parent88eecd2280754f1602bbaf58af020be5672e5a0c (diff)
downloadappstream-glib-70dd12823ed224f52e0777f4217870060b8a2394.tar.gz
Do not save the XML attributes if the node or parent node is being ignored
This makes things a bit quicker to load and saves over 5Mb RSS on the giant Fedora AppStream file.
-rw-r--r--libappstream-glib/as-node.c30
1 files changed, 19 insertions, 11 deletions
diff --git a/libappstream-glib/as-node.c b/libappstream-glib/as-node.c
index f793274..cbf2364 100644
--- a/libappstream-glib/as-node.c
+++ b/libappstream-glib/as-node.c
@@ -495,14 +495,8 @@ as_node_start_element_cb (GMarkupParseContext *context,
gchar *tmp;
guint i;
- /* create the new node data */
+ /* check if we should ignore the locale */
data = g_slice_new0 (AsNodeData);
- as_node_data_set_name (data, element_name, AS_NODE_INSERT_FLAG_NONE);
- for (i = 0; attribute_names[i] != NULL; i++) {
- as_node_attr_insert (data,
- attribute_names[i],
- attribute_values[i]);
- }
/* parent node is being ignored */
data_parent = helper->current->data;
@@ -510,11 +504,25 @@ as_node_start_element_cb (GMarkupParseContext *context,
data->cdata_ignore = TRUE;
/* check if we should ignore the locale */
- if (helper->flags & AS_NODE_FROM_XML_FLAG_ONLY_NATIVE_LANGS) {
- const gchar *lang = as_node_attr_lookup (data, "xml:lang");
- if (lang != NULL && !g_strv_contains (helper->locales, lang))
- data->cdata_ignore = TRUE;
+ if (!data->cdata_ignore &&
+ helper->flags & AS_NODE_FROM_XML_FLAG_ONLY_NATIVE_LANGS) {
+ for (i = 0; attribute_names[i] != NULL; i++) {
+ if (g_strcmp0 (attribute_names[i], "xml:lang") == 0) {
+ const gchar *lang = attribute_values[i];
+ if (lang != NULL && !g_strv_contains (helper->locales, lang))
+ data->cdata_ignore = TRUE;
+ }
+ }
+ }
+ /* create the new node data */
+ if (!data->cdata_ignore) {
+ as_node_data_set_name (data, element_name, AS_NODE_INSERT_FLAG_NONE);
+ for (i = 0; attribute_names[i] != NULL; i++) {
+ as_node_attr_insert (data,
+ attribute_names[i],
+ attribute_values[i]);
+ }
}
/* add the node to the DOM */