gnucash stable: Multiple changes pushed

Christopher Lam clam at code.gnucash.org
Wed Jul 26 11:22:20 EDT 2023


Updated	 via  https://github.com/Gnucash/gnucash/commit/41724687 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/31471095 (commit)
	from  https://github.com/Gnucash/gnucash/commit/ffe7011f (commit)



commit 417246879a7e4a5f4d68670eb2c33d5df66b9784
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Wed Jul 26 22:14:29 2023 +0800

    [import-main-matcher] always defer_bal_computation during import
    
    This will speed up both importing new transactions, and destroying
    existing ones.

diff --git a/gnucash/import-export/import-main-matcher.cpp b/gnucash/import-export/import-main-matcher.cpp
index 36d1cad898..ea00d9f770 100644
--- a/gnucash/import-export/import-main-matcher.cpp
+++ b/gnucash/import-export/import-main-matcher.cpp
@@ -2224,6 +2224,10 @@ gnc_gen_trans_list_add_trans_internal (GNCImportMainMatcher *gui, Transaction *t
     g_assert (gui);
     g_assert (trans);
 
+    Split *split = xaccTransGetSplit (trans, 0);
+    Account *acc = xaccSplitGetAccount (split);
+    defer_bal_computation (gui, acc);
+
     if (gnc_import_exists_online_id (trans, gui->acct_id_hash))
     {
         /* If it does, abort the process for this transaction, since
@@ -2234,10 +2238,6 @@ gnc_gen_trans_list_add_trans_internal (GNCImportMainMatcher *gui, Transaction *t
         return;
     }
 
-    Split *split = xaccTransGetSplit (trans, 0);
-    Account *acc = xaccSplitGetAccount (split);
-    defer_bal_computation (gui, acc);
-
     GNCImportTransInfo *transaction_info = gnc_import_TransInfo_new (trans, NULL);
     gnc_import_TransInfo_set_ref_id (transaction_info, ref_id);
     gnc_import_TransInfo_set_last_split_info (transaction_info, lsplit);

commit 314710953f31bbf592ac541e349c2df0020c054a
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Wed Jul 26 09:19:52 2023 +0800

    Revert recent changes from #1725 to import-main-matcher.cpp
    
    because there's a better strategy, in next commit

diff --git a/gnucash/import-export/aqb/gnc-ab-utils.c b/gnucash/import-export/aqb/gnc-ab-utils.c
index f88c134447..0d7b6e0d8a 100644
--- a/gnucash/import-export/aqb/gnc-ab-utils.c
+++ b/gnucash/import-export/aqb/gnc-ab-utils.c
@@ -872,7 +872,6 @@ txn_accountinfo_cb (AB_IMEXPORTER_ACCOUNTINFO *element, gpointer user_data)
                                                txn_transaction_cb, data,
                                                AB_Transaction_TypeStatement, 0);
     }
-    gnc_gen_trans_list_purge_existing (data->generic_importer);
     return NULL;
 }
 
diff --git a/gnucash/import-export/csv-imp/assistant-csv-trans-import.cpp b/gnucash/import-export/csv-imp/assistant-csv-trans-import.cpp
index 04f9668576..55823b93b1 100644
--- a/gnucash/import-export/csv-imp/assistant-csv-trans-import.cpp
+++ b/gnucash/import-export/csv-imp/assistant-csv-trans-import.cpp
@@ -2183,8 +2183,6 @@ CsvImpTransAssist::assist_match_page_prepare ()
             draft_trans->trans = nullptr;
         }
     }
-
-    gnc_gen_trans_list_purge_existing(gnc_csv_importer_gui);
     /* Show the matcher dialog */
     gnc_gen_trans_list_show_all (gnc_csv_importer_gui);
 }
diff --git a/gnucash/import-export/import-main-matcher.cpp b/gnucash/import-export/import-main-matcher.cpp
index 6824341b6e..36d1cad898 100644
--- a/gnucash/import-export/import-main-matcher.cpp
+++ b/gnucash/import-export/import-main-matcher.cpp
@@ -39,8 +39,6 @@
 #include <stdbool.h>
 
 #include <vector>
-#include <unordered_set>
-#include <algorithm>
 
 #include "import-main-matcher.h"
 
@@ -80,7 +78,6 @@ struct _main_matcher_info
     GtkWidget               *show_matched_info;
     GtkWidget               *append_text; // Update+Clear: Append import Desc/Notes to matched Desc/Notes
     GtkWidget               *reconcile_after_close;
-    std::vector<Transaction*> transactions_to_delete; // transactions to delete immediately instead of importing
     bool add_toggled;     // flag to indicate that add has been toggled to stop selection
     gint id;
     GSList* temp_trans_list;  // Temporary list of imported transactions
@@ -2232,7 +2229,8 @@ gnc_gen_trans_list_add_trans_internal (GNCImportMainMatcher *gui, Transaction *t
         /* If it does, abort the process for this transaction, since
            it is already in the system. */
         DEBUG("%s", "Transaction with same online ID exists, destroying current transaction");
-        gui->transactions_to_delete.push_back (trans);
+        xaccTransDestroy(trans);
+        xaccTransCommitEdit(trans);
         return;
     }
 
@@ -2248,31 +2246,6 @@ gnc_gen_trans_list_add_trans_internal (GNCImportMainMatcher *gui, Transaction *t
     gui->temp_trans_list = g_slist_prepend (gui->temp_trans_list, transaction_info);
 }
 
-void
-gnc_gen_trans_list_purge_existing (GNCImportMainMatcher *gui)
-{
-    g_return_if_fail (gui);
-    std::unordered_set<Account*> accset;
-    std::for_each (gui->transactions_to_delete.begin(), gui->transactions_to_delete.end(),
-                   [&accset](const Transaction* txn)
-                   {
-                       for (auto n = xaccTransGetSplitList (txn); n; n = n->next)
-                       {
-                           auto acc{xaccSplitGetAccount (static_cast<const Split*>(n->data))};
-                           if (accset.insert(acc).second)
-                               xaccAccountBeginEdit (acc);
-                       }
-                   });
-    std::for_each (gui->transactions_to_delete.begin(), gui->transactions_to_delete.end(),
-                   [](Transaction* txn)
-                   {
-                       xaccTransDestroy (txn);
-                       xaccTransCommitEdit (txn);
-                   });
-    std::for_each (accset.begin(), accset.end(), xaccAccountCommitEdit);
-    gui->transactions_to_delete.clear();
-}
-
 void
 gnc_gen_trans_list_add_trans (GNCImportMainMatcher *gui, Transaction *trans)
 {
diff --git a/gnucash/import-export/import-main-matcher.h b/gnucash/import-export/import-main-matcher.h
index c84ca8f20d..cf0120333f 100644
--- a/gnucash/import-export/import-main-matcher.h
+++ b/gnucash/import-export/import-main-matcher.h
@@ -200,16 +200,6 @@ void gnc_gen_trans_list_add_trans_with_ref_id (GNCImportMainMatcher *gui,
                                                guint32 ref_id);
 
 
-/** Performs housekeeping for the previous related functions
- * gnc_gen_trans_list_add_trans etc -- these functions will add (or
- * mark for destroy) transactions for import. This function will
- * actually efficiently destroy the transactions already imported.
- *
- * @param gui The Transaction Importer to use.
- */
-
-void gnc_gen_trans_list_purge_existing (GNCImportMainMatcher *gui);
-
 /** Run this dialog and return only after the user pressed Ok, Cancel,
   or closed the window. This means that all actual importing will
   have been finished upon returning.
diff --git a/gnucash/import-export/ofx/gnc-ofx-import.cpp b/gnucash/import-export/ofx/gnc-ofx-import.cpp
index d8c6a2ebb3..21d1f6b558 100644
--- a/gnucash/import-export/ofx/gnc-ofx-import.cpp
+++ b/gnucash/import-export/ofx/gnc-ofx-import.cpp
@@ -1339,7 +1339,6 @@ runMatcher (ofx_info* info, char * selected_filename, gboolean go_to_next_file)
             info->num_trans_processed ++;
         }
     }
-    gnc_gen_trans_list_purge_existing (info->gnc_ofx_importer_gui);
     g_list_free (info->trans_list);
     g_hash_table_destroy (trans_hash);
     info->trans_list = g_list_reverse (trans_list_remain);



Summary of changes:
 gnucash/import-export/aqb/gnc-ab-utils.c           |  1 -
 .../csv-imp/assistant-csv-trans-import.cpp         |  2 --
 gnucash/import-export/import-main-matcher.cpp      | 39 ++++------------------
 gnucash/import-export/import-main-matcher.h        | 10 ------
 gnucash/import-export/ofx/gnc-ofx-import.cpp       |  1 -
 5 files changed, 6 insertions(+), 47 deletions(-)



More information about the gnucash-changes mailing list