[gnome-software/wip/setup-shell-only-after-plugin-loader-is-setup] gs-category: Add 'value' argument to the gs_category_increment_size()
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/wip/setup-shell-only-after-plugin-loader-is-setup] gs-category: Add 'value' argument to the gs_category_increment_size()
- Date: Wed, 25 May 2022 10:08:45 +0000 (UTC)
commit 006efa2cd77dd2642d7fa998445d57a8791f0065
Author: Milan Crha <mcrha redhat com>
Date: Wed May 25 12:03:39 2022 +0200
gs-category: Add 'value' argument to the gs_category_increment_size()
Rather than increment by one, increment by the needed number, to save
some CPU time.
lib/gs-appstream.c | 6 +++---
lib/gs-category.c | 8 +++++---
lib/gs-category.h | 3 ++-
3 files changed, 10 insertions(+), 7 deletions(-)
---
diff --git a/lib/gs-appstream.c b/lib/gs-appstream.c
index 38cc31bb5..c73adce6d 100644
--- a/lib/gs-appstream.c
+++ b/lib/gs-appstream.c
@@ -1626,12 +1626,12 @@ gs_appstream_add_categories (XbSilo *silo,
for (guint k = 0; k < groups->len; k++) {
const gchar *group = g_ptr_array_index (groups, k);
guint cnt = gs_appstream_count_component_for_groups (silo, group);
- for (guint l = 0; l < cnt; l++) {
- gs_category_increment_size (parent);
+ if (cnt > 0) {
+ gs_category_increment_size (parent, cnt);
if (children->len > 1) {
/* Parent category has multiple groups, so increment
* each group's size too */
- gs_category_increment_size (cat);
+ gs_category_increment_size (cat, cnt);
}
}
}
diff --git a/lib/gs-category.c b/lib/gs-category.c
index b311c4941..4baede3bc 100644
--- a/lib/gs-category.c
+++ b/lib/gs-category.c
@@ -147,17 +147,19 @@ gs_category_set_size (GsCategory *category, guint size)
/**
* gs_category_increment_size:
* @category: a #GsCategory
+ * @value: how many to add
*
- * Adds one to the size count if an application is available
+ * Adds @value to the size count.
*
* Since: 3.22
**/
void
-gs_category_increment_size (GsCategory *category)
+gs_category_increment_size (GsCategory *category,
+ guint value)
{
g_return_if_fail (GS_IS_CATEGORY (category));
- category->size++;
+ category->size += value;
g_object_notify_by_pspec (G_OBJECT (category), obj_props[PROP_SIZE]);
}
diff --git a/lib/gs-category.h b/lib/gs-category.h
index ecd2e1e23..1e82591aa 100644
--- a/lib/gs-category.h
+++ b/lib/gs-category.h
@@ -39,6 +39,7 @@ GsCategory *gs_category_find_child (GsCategory *category,
GPtrArray *gs_category_get_children (GsCategory *category);
guint gs_category_get_size (GsCategory *category);
-void gs_category_increment_size (GsCategory *category);
+void gs_category_increment_size (GsCategory *category,
+ guint value);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]