summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKalev Lember <klember@redhat.com>2018-12-14 11:52:19 +0100
committerKalev Lember <klember@redhat.com>2018-12-14 13:44:33 +0100
commit0f79c943948abb62a54d0e54b1135ff89ebf5ab4 (patch)
treea753d7ec87d3c8cdec9542ccf7ac66bbf014a6d9
parente5f73b24c4950ec8e51f6970ad658d604baf6d24 (diff)
downloadappstream-glib-0f79c943948abb62a54d0e54b1135ff89ebf5ab4.tar.gz
store: Return deep copy in as_store_get_apps_by_metadata
This is strictly not necessary for making gnome-software's AsStore use thread safe as gnome-software doesn't actually use this function, but let's fix it anyway while I'm at it. This also updates tests that test the performance of the function as the deep copying makes it noticably slower (but that's fine because nothing actually uses it and it's still reasonably fast).
-rw-r--r--libappstream-glib/as-self-test.c2
-rw-r--r--libappstream-glib/as-store.c2
2 files changed, 2 insertions, 2 deletions
diff --git a/libappstream-glib/as-self-test.c b/libappstream-glib/as-self-test.c
index 7fd7d75..981b790 100644
--- a/libappstream-glib/as-self-test.c
+++ b/libappstream-glib/as-self-test.c
@@ -4730,7 +4730,7 @@ static void
as_test_store_metadata_index_func (void)
{
GPtrArray *apps;
- const guint repeats = 10000;
+ const guint repeats = 500;
guint i;
g_autoptr(AsStore) store = NULL;
g_autoptr(GTimer) timer = NULL;
diff --git a/libappstream-glib/as-store.c b/libappstream-glib/as-store.c
index 59a7f1c..018bdb5 100644
--- a/libappstream-glib/as-store.c
+++ b/libappstream-glib/as-store.c
@@ -473,7 +473,7 @@ as_store_get_apps_by_metadata (AsStore *store,
}
apps = g_hash_table_lookup (index, value);
if (apps != NULL)
- return g_ptr_array_ref (apps);
+ return _dup_app_array (apps);
return g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
}