[gnome-software] gs-plugin-loader: Only do an early refine if sorting results



commit a24b1e0b28ce8b7c36fff81e4217ac106f6b5af0
Author: Philip Withnall <withnall endlessm com>
Date:   Thu Apr 2 23:29:16 2020 +0100

    gs-plugin-loader: Only do an early refine if sorting results
    
    `gs_plugin_loader_process_thread_cb()` refines the app list it’s working
    on twice: once with a minimal set of refine flags so that the app list
    can be sorted and truncated; and then again on the truncated app list
    with a wider set of refine flags. Finally, it sorts the results again
    (without truncation).
    
    Often, however, the truncation step is a no-op. In this case, the
    sorting and initial refine are unnecessary, but they were still being
    done. As both a refine and a sort happen later anyway, this was
    redundant.
    
    Adding a check to skip the initial refine if no truncation is going to
    happen reduced the time needed for a `get-category-apps` operation on a
    large category from 2.5s to 1.7s (-32%).
    
    Signed-off-by: Philip Withnall <withnall endlessm com>

 lib/gs-plugin-loader.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
---
diff --git a/lib/gs-plugin-loader.c b/lib/gs-plugin-loader.c
index 8ab51db5..74e9db58 100644
--- a/lib/gs-plugin-loader.c
+++ b/lib/gs-plugin-loader.c
@@ -3062,6 +3062,7 @@ gs_plugin_loader_process_thread_cb (GTask *task,
        GsPluginRefineFlags filter_flags;
        GsPluginRefineFlags refine_flags;
        gboolean add_to_pending_array = FALSE;
+       guint max_results;
 
        /* these change the pending count on the installed panel */
        switch (action) {
@@ -3173,9 +3174,11 @@ gs_plugin_loader_process_thread_cb (GTask *task,
                break;
        }
 
-       /* refine with enough data so that the sort_func can do what it needs */
+       /* refine with enough data so that the sort_func in
+        * gs_plugin_loader_job_sorted_truncation() can do what it needs */
        filter_flags = gs_plugin_job_get_filter_flags (helper->plugin_job);
-       if (filter_flags > 0) {
+       max_results = gs_plugin_job_get_max_results (helper->plugin_job);
+       if (filter_flags > 0 && max_results > 0) {
                g_autoptr(GsPluginLoaderHelper) helper2 = NULL;
                g_autoptr(GsPluginJob) plugin_job = NULL;
                plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_REFINE,


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