[gnome-software: 1/2] flatpak: Improve performance of progress reporting
- From: Philip Withnall <pwithnall src gnome org>
 
- To: commits-list gnome org
 
- Cc: 
 
- Subject: [gnome-software: 1/2] flatpak: Improve performance of progress reporting
 
- Date: Tue, 15 Dec 2020 10:59:06 +0000 (UTC)
 
commit bcda638250523b611c44c4285da401fe4d03fcb4
Author: Philip Withnall <pwithnall endlessos org>
Date:   Sat Dec 12 19:57:24 2020 +0000
    flatpak: Improve performance of progress reporting
    
    The `_ref_to_app()` function is called O(log N) times for each call to
    `_transaction_progress_changed_cb()`, for each of the log N transaction
    ops which are ancestors of the current op in the op tree. Each call to
    `_ref_to_app()` results in a call to
    `flatpak_installation_list_remote_refs_sync_full()`, which is not fast.
    
    Cache the ref/app mappings so this doesn’t have to happen an order of
    magnitude as often.
    
    Signed-off-by: Philip Withnall <pwithnall endlessos org>
 plugins/flatpak/gs-flatpak-transaction.c | 5 +++++
 1 file changed, 5 insertions(+)
---
diff --git a/plugins/flatpak/gs-flatpak-transaction.c b/plugins/flatpak/gs-flatpak-transaction.c
index eb89b8db..e1c74725 100644
--- a/plugins/flatpak/gs-flatpak-transaction.c
+++ b/plugins/flatpak/gs-flatpak-transaction.c
@@ -101,6 +101,11 @@ _ref_to_app (GsFlatpakTransaction *self, const gchar *ref)
        if (app != NULL)
                return g_object_ref (app);
        g_signal_emit (self, signals[SIGNAL_REF_TO_APP], 0, ref, &app);
+
+       /* Cache the result */
+       if (app != NULL)
+               g_hash_table_insert (self->refhash, g_strdup (ref), g_object_ref (app));
+
        return app;
 }
 
[
Date Prev][
Date Next]   [
Thread Prev][
Thread Next]   
[
Thread Index]
[
Date Index]
[
Author Index]