diff options
author | Richard Hughes <richard@hughsie.com> | 2016-11-17 13:52:57 +0000 |
---|---|---|
committer | Richard Hughes <richard@hughsie.com> | 2016-11-21 15:19:55 +0000 |
commit | 405c1b011631895ba89248b5545603cea43bcf16 (patch) | |
tree | 45a6bd373fc3da1c0bf150b0b6e438be06f58f98 | |
parent | 1e2dac494cb31234ce19e9eccac11ee920765a82 (diff) | |
download | appstream-glib-405c1b011631895ba89248b5545603cea43bcf16.tar.gz |
Use refcounted strings as the localised key
Saves 0.02Mb RSS.
-rw-r--r-- | libappstream-glib/as-node.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/libappstream-glib/as-node.c b/libappstream-glib/as-node.c index 0953ec2..ffbdd6b 100644 --- a/libappstream-glib/as-node.c +++ b/libappstream-glib/as-node.c @@ -1657,6 +1657,7 @@ as_node_get_localized (const AsNode *node, const gchar *key) const gchar *data_localized; GHashTable *hash = NULL; AsNode *tmp; + g_autoptr(AsRefString) xml_lang_c = as_ref_string_new_copy ("C"); /* does it exist? */ tmp = as_node_get_child_node (node, key, NULL, NULL); @@ -1665,7 +1666,8 @@ as_node_get_localized (const AsNode *node, const gchar *key) data_unlocalized = as_node_get_data (tmp); /* find a node called name */ - hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); + hash = g_hash_table_new_full (g_str_hash, g_str_equal, + (GDestroyNotify) as_ref_string_unref, NULL); for (tmp = node->children; tmp != NULL; tmp = tmp->next) { data = tmp->data; if (data == NULL) @@ -1683,7 +1685,7 @@ as_node_get_localized (const AsNode *node, const gchar *key) if (xml_lang != NULL && g_strcmp0 (data_unlocalized, data_localized) == 0) continue; g_hash_table_insert (hash, - g_strdup (xml_lang != NULL ? xml_lang : "C"), + as_ref_string_ref (xml_lang != NULL ? xml_lang : xml_lang_c), (gpointer) data_localized); } return hash; |