summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2018-05-18 15:06:53 +0100
committerRichard Hughes <richard@hughsie.com>2018-05-21 17:16:29 +0100
commit6782a91adeb876dddb7501d00ed51eb9ce75d6eb (patch)
treeada262487a323b3d31c7d47ac93d31d62e571d12
parent176b89438ee337ea67f9ba39f1cf9be672a2d974 (diff)
downloadappstream-glib-6782a91adeb876dddb7501d00ed51eb9ce75d6eb.tar.gz
trivial: Do not reallocate all the AsImage URL strings
-rw-r--r--libappstream-glib/as-image-private.h2
-rw-r--r--libappstream-glib/as-image.c7
-rw-r--r--libappstream-glib/as-screenshot.c7
3 files changed, 13 insertions, 3 deletions
diff --git a/libappstream-glib/as-image-private.h b/libappstream-glib/as-image-private.h
index 47f98c7..927cbe7 100644
--- a/libappstream-glib/as-image-private.h
+++ b/libappstream-glib/as-image-private.h
@@ -42,6 +42,8 @@ gboolean as_image_node_parse_dep11 (AsImage *image,
GNode *node,
AsNodeContext *ctx,
GError **error);
+void as_image_set_url_rstr (AsImage *image,
+ AsRefString *rstr);
G_END_DECLS
diff --git a/libappstream-glib/as-image.c b/libappstream-glib/as-image.c
index 6949e71..5b6f1f9 100644
--- a/libappstream-glib/as-image.c
+++ b/libappstream-glib/as-image.c
@@ -281,6 +281,13 @@ as_image_set_url (AsImage *image, const gchar *url)
as_ref_string_assign_safe (&priv->url, url);
}
+void
+as_image_set_url_rstr (AsImage *image, AsRefString *rstr)
+{
+ AsImagePrivate *priv = GET_PRIVATE (image);
+ as_ref_string_assign (&priv->url, rstr);
+}
+
/**
* as_image_set_basename:
* @image: a #AsImage instance.
diff --git a/libappstream-glib/as-screenshot.c b/libappstream-glib/as-screenshot.c
index ab8cb92..1e479f3 100644
--- a/libappstream-glib/as-screenshot.c
+++ b/libappstream-glib/as-screenshot.c
@@ -469,6 +469,7 @@ as_screenshot_node_parse (AsScreenshot *screenshot, GNode *node,
AsNodeContext *ctx, GError **error)
{
AsScreenshotPrivate *priv = GET_PRIVATE (screenshot);
+ AsRefString *str;
GList *l;
GNode *c;
const gchar *tmp;
@@ -499,8 +500,8 @@ as_screenshot_node_parse (AsScreenshot *screenshot, GNode *node,
}
/* AppData files does not have <image> tags */
- tmp = as_node_get_data (node);
- if (tmp != NULL) {
+ str = as_node_get_data_as_refstr (node);
+ if (str != NULL) {
AsImage *image;
image = as_image_new ();
as_image_set_kind (image, AS_IMAGE_KIND_SOURCE);
@@ -510,7 +511,7 @@ as_screenshot_node_parse (AsScreenshot *screenshot, GNode *node,
size = as_node_get_attribute_as_uint (node, "height");
if (size != G_MAXUINT)
as_image_set_height (image, size);
- as_image_set_url (image, tmp);
+ as_image_set_url_rstr (image, str);
g_ptr_array_add (priv->images, image);
}