[gnome-software: 7/9] gs-plugin-loader: Remove a filter pass to copy plugin priorities to apps




commit e11a60b4a2ddadacbfbb1a8325b1e8daee574138
Author: Philip Withnall <pwithnall endlessos org>
Date:   Tue Nov 23 16:51:12 2021 +0000

    gs-plugin-loader: Remove a filter pass to copy plugin priorities to apps
    
    Now that `gs_app_get_priority()` can default to returning its plugin’s
    priority, an explicit filter pass (run as part of most plugin jobs) is
    unnecessary.
    
    This should improve performance, but I haven’t measured it. The change
    is probably not significant.
    
    Signed-off-by: Philip Withnall <pwithnall endlessos org>

 lib/gs-app.c           | 14 ++++++++++++--
 lib/gs-plugin-loader.c | 14 --------------
 2 files changed, 12 insertions(+), 16 deletions(-)
---
diff --git a/lib/gs-app.c b/lib/gs-app.c
index 6e5af3f07..91cc8d50c 100644
--- a/lib/gs-app.c
+++ b/lib/gs-app.c
@@ -48,6 +48,7 @@
 #include "gs-key-colors.h"
 #include "gs-os-release.h"
 #include "gs-plugin.h"
+#include "gs-plugin-private.h"
 #include "gs-remote-icon.h"
 #include "gs-utils.h"
 
@@ -564,8 +565,8 @@ gs_app_to_string_append (GsApp *app, GString *str)
        }
        if (priv->match_value != 0)
                gs_app_kv_printf (str, "match-value", "%05x", priv->match_value);
-       if (priv->priority != 0)
-               gs_app_kv_printf (str, "priority", "%u", priv->priority);
+       if (gs_app_get_priority (app) != 0)
+               gs_app_kv_printf (str, "priority", "%u", gs_app_get_priority (app));
        if (priv->version != NULL)
                gs_app_kv_lpad (str, "version", priv->version);
        if (priv->version_ui != NULL)
@@ -4807,6 +4808,15 @@ gs_app_get_priority (GsApp *app)
 {
        GsAppPrivate *priv = gs_app_get_instance_private (app);
        g_return_val_if_fail (GS_IS_APP (app), 0);
+
+       /* If the priority hasn’t been explicitly set, fetch it from the app’s
+        * management plugin. */
+       if (priv->priority == 0) {
+               g_autoptr(GsPlugin) plugin = gs_app_dup_management_plugin (app);
+               if (plugin != NULL)
+                       return gs_plugin_get_priority (plugin);
+       }
+
        return priv->priority;
 }
 
diff --git a/lib/gs-plugin-loader.c b/lib/gs-plugin-loader.c
index a76cd64ab..19e958ece 100644
--- a/lib/gs-plugin-loader.c
+++ b/lib/gs-plugin-loader.c
@@ -1293,19 +1293,6 @@ gs_plugin_loader_get_app_str (GsApp *app)
        return "<invalid>";
 }
 
-static gboolean
-gs_plugin_loader_app_set_prio (GsApp *app, gpointer user_data)
-{
-       g_autoptr(GsPlugin) plugin = NULL;
-
-       /* if set, copy the priority */
-       plugin = gs_app_dup_management_plugin (app);
-       if (plugin == NULL)
-               return TRUE;
-       gs_app_set_priority (app, gs_plugin_get_priority (plugin));
-       return TRUE;
-}
-
 static gboolean
 gs_plugin_loader_app_is_valid_installed (GsApp *app, gpointer user_data)
 {
@@ -3616,7 +3603,6 @@ gs_plugin_loader_process_thread_cb (GTask *task,
 
        /* filter duplicates with priority, taking into account the source name
         * & version, so we combine available updates with the installed app */
-       gs_app_list_filter (list, gs_plugin_loader_app_set_prio, plugin_loader);
        dedupe_flags = gs_plugin_job_get_dedupe_flags (helper->plugin_job);
        if (dedupe_flags != GS_APP_LIST_FILTER_FLAG_NONE)
                gs_app_list_filter_duplicates (list, dedupe_flags);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]