[gnome-software] trivial: Optimise gs_plugin_add_categories() a few cycles
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] trivial: Optimise gs_plugin_add_categories() a few cycles
- Date: Fri, 29 Nov 2013 16:07:31 +0000 (UTC)
commit 90ef9fd226e37084c38395d50322c75da378eb5c
Author: Richard Hughes <richard hughsie com>
Date: Fri Nov 29 16:06:58 2013 +0000
trivial: Optimise gs_plugin_add_categories() a few cycles
src/plugins/gs-plugin-appstream.c | 17 ++++++-----------
1 files changed, 6 insertions(+), 11 deletions(-)
---
diff --git a/src/plugins/gs-plugin-appstream.c b/src/plugins/gs-plugin-appstream.c
index 26fee2e..90b11a0 100644
--- a/src/plugins/gs-plugin-appstream.c
+++ b/src/plugins/gs-plugin-appstream.c
@@ -858,31 +858,26 @@ gs_plugin_add_categories (GsPlugin *plugin,
/* find out how many packages are in each category */
gs_profile_start (plugin->profile, "appstream::add-categories");
+ array = appstream_cache_get_items (plugin->priv->cache);
for (l = *list; l != NULL; l = l->next) {
parent = GS_CATEGORY (l->data);
+ search_id2 = gs_category_get_id (parent);
children = gs_category_get_subcategories (parent);
for (l2 = children; l2 != NULL; l2 = l2->next) {
category = GS_CATEGORY (l2->data);
- search_id1 = gs_category_get_id (category);
- search_id2 = gs_category_get_id (parent);
-
- /* the "General" item has no ID */
- if (search_id1 == NULL) {
- search_id1 = search_id2;
- search_id2 = NULL;
- }
/* just look at each app in turn */
- array = appstream_cache_get_items (plugin->priv->cache);
for (i = 0; i < array->len; i++) {
item = g_ptr_array_index (array, i);
if (appstream_app_get_id (item) == NULL)
continue;
if (appstream_app_get_priority (item) < 0)
continue;
- if (!appstream_app_has_category (item, search_id1))
+ if (!appstream_app_has_category (item, search_id2))
continue;
- if (search_id2 != NULL && !appstream_app_has_category (item, search_id2))
+ search_id1 = gs_category_get_id (category);
+ if (search_id1 != NULL &&
+ !appstream_app_has_category (item, search_id1))
continue;
/* we have another result */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]