summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2018-05-18 15:15:27 +0100
committerRichard Hughes <richard@hughsie.com>2018-05-21 17:16:29 +0100
commitb5ab36a74aec00c2fe41cfc0db804fe1465513a9 (patch)
tree95be0e3e4ffbad656e3ad0d17fbab806d9c99d48
parent1bee3cd81fa6151551bcff451548a0e1a9e69dbf (diff)
downloadappstream-glib-b5ab36a74aec00c2fe41cfc0db804fe1465513a9.tar.gz
trivial: Do not duplicate tiny strings for each <lang> and <caption> tag
-rw-r--r--libappstream-glib/as-app.c5
-rw-r--r--libappstream-glib/as-screenshot.c10
2 files changed, 9 insertions, 6 deletions
diff --git a/libappstream-glib/as-app.c b/libappstream-glib/as-app.c
index 43a0008..3707b55 100644
--- a/libappstream-glib/as-app.c
+++ b/libappstream-glib/as-app.c
@@ -5322,8 +5322,9 @@ as_app_node_parse_child (AsApp *app, GNode *n, guint32 flags,
percent = as_node_get_attribute_as_int (c, "percentage");
if (percent == G_MAXINT)
percent = 0;
- as_app_add_language (app, percent,
- as_node_get_data (c));
+ g_hash_table_insert (priv->languages,
+ as_ref_string_ref (as_node_get_data_as_refstr (c)),
+ GINT_TO_POINTER (percent));
}
if (n->children == NULL)
priv->problems |= AS_APP_PROBLEM_EXPECTED_CHILDREN;
diff --git a/libappstream-glib/as-screenshot.c b/libappstream-glib/as-screenshot.c
index 1e479f3..d4c7245 100644
--- a/libappstream-glib/as-screenshot.c
+++ b/libappstream-glib/as-screenshot.c
@@ -490,12 +490,14 @@ as_screenshot_node_parse (AsScreenshot *screenshot, GNode *node,
captions = as_node_get_localized (node, "caption");
if (captions != NULL) {
g_autoptr(GList) keys = NULL;
+ as_screenshot_ensure_captions (screenshot);
keys = g_hash_table_get_keys (captions);
for (l = keys; l != NULL; l = l->next) {
- tmp = l->data;
- as_screenshot_set_caption (screenshot,
- tmp,
- g_hash_table_lookup (captions, tmp));
+ AsRefString *locale = l->data;
+ AsRefString *caption = g_hash_table_lookup (captions, locale);
+ g_hash_table_insert (priv->captions,
+ as_ref_string_ref (locale),
+ as_ref_string_ref (caption));
}
}