[gnome-software/wip/hughsie/flatpak-profile] trivial: Generate the search token cache at setup time
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/wip/hughsie/flatpak-profile] trivial: Generate the search token cache at setup time
- Date: Wed, 2 Nov 2016 10:00:41 +0000 (UTC)
commit 005d2d6c2d7590f82b2278a7beb9070b16e05f42
Author: Richard Hughes <richard hughsie com>
Date: Wed Nov 2 09:22:14 2016 +0000
trivial: Generate the search token cache at setup time
This should give us some more accurate profiling numbers for the initial
search operation.
src/plugins/gs-appstream.c | 20 ++++++++++++++++++++
src/plugins/gs-appstream.h | 2 ++
src/plugins/gs-flatpak.c | 3 +++
src/plugins/gs-plugin-appstream.c | 3 +++
4 files changed, 28 insertions(+), 0 deletions(-)
---
diff --git a/src/plugins/gs-appstream.c b/src/plugins/gs-appstream.c
index 1546ee0..952c7ee 100644
--- a/src/plugins/gs-appstream.c
+++ b/src/plugins/gs-appstream.c
@@ -800,6 +800,26 @@ gs_appstream_store_search_item (GsPlugin *plugin,
return TRUE;
}
+void
+gs_appstream_ensure_app_token_cache (GsPlugin *plugin, AsStore *store)
+{
+ GPtrArray *array;
+ guint i;
+ g_autoptr(AsProfileTask) ptask = NULL;
+
+ /* profile */
+ ptask = as_profile_start_literal (gs_plugin_get_profile (plugin),
+ "appstream::create-token-cache");
+ g_assert (ptask != NULL);
+
+ /* prime the search cache */
+ array = as_store_get_apps (store);
+ for (i = 0; i < array->len; i++) {
+ AsApp *app = g_ptr_array_index (array, i);
+ as_app_search_matches (app, NULL);
+ }
+}
+
gboolean
gs_appstream_store_search (GsPlugin *plugin,
AsStore *store,
diff --git a/src/plugins/gs-appstream.h b/src/plugins/gs-appstream.h
index d8651bd..4c137ca 100644
--- a/src/plugins/gs-appstream.h
+++ b/src/plugins/gs-appstream.h
@@ -63,6 +63,8 @@ gboolean gs_appstream_add_featured (GsPlugin *plugin,
GsAppList *list,
GCancellable *cancellable,
GError **error);
+void gs_appstream_ensure_app_token_cache (GsPlugin *plugin,
+ AsStore *store);
G_END_DECLS
diff --git a/src/plugins/gs-flatpak.c b/src/plugins/gs-flatpak.c
index 22553c8..28b1de7 100644
--- a/src/plugins/gs-flatpak.c
+++ b/src/plugins/gs-flatpak.c
@@ -233,6 +233,9 @@ gs_flatpak_add_apps_from_xremote (GsFlatpak *self,
return FALSE;
}
+ /* ensure the token cache */
+ gs_appstream_ensure_app_token_cache (self->plugin, store);
+
/* only add the specific app for noenumerate=true */
if (flatpak_remote_get_noenumerate (xremote)) {
g_autofree gchar *tmp = NULL;
diff --git a/src/plugins/gs-plugin-appstream.c b/src/plugins/gs-plugin-appstream.c
index 0b861a3..13057b6 100644
--- a/src/plugins/gs-plugin-appstream.c
+++ b/src/plugins/gs-plugin-appstream.c
@@ -279,6 +279,9 @@ gs_plugin_setup (GsPlugin *plugin, GCancellable *cancellable, GError **error)
G_CALLBACK (gs_plugin_appstream_store_app_removed_cb),
plugin);
+ /* ensure the token cache */
+ gs_appstream_ensure_app_token_cache (plugin, priv->store);
+
/* add search terms for apps not in the main source */
origins = gs_plugin_appstream_get_origins_hash (items);
for (i = 0; i < items->len; i++) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]