gnucash stable: Multiple changes pushed

Christopher Lam clam at code.gnucash.org
Sun Nov 2 21:57:41 EST 2025


Updated	 via  https://github.com/Gnucash/gnucash/commit/dde10464 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/655bddda (commit)
	 via  https://github.com/Gnucash/gnucash/commit/001c690a (commit)
	from  https://github.com/Gnucash/gnucash/commit/0b66ee3b (commit)



commit dde10464d1bd0bafb6ba44af7a18680e0cf2b08b
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sun Nov 2 22:28:25 2025 +0800

    [transaction.cpp] comparing identical txns returns 0
    
    bypassing many comparisons

diff --git a/libgnucash/engine/Transaction.cpp b/libgnucash/engine/Transaction.cpp
index 51c7ee7ae8..32f6f3cb9c 100644
--- a/libgnucash/engine/Transaction.cpp
+++ b/libgnucash/engine/Transaction.cpp
@@ -1829,9 +1829,9 @@ xaccTransOrder_num_action (const Transaction *ta, const char *actna,
     const char *da, *db;
     int retval;
 
-    if ( ta && !tb ) return -1;
-    if ( !ta && tb ) return +1;
-    if ( !ta && !tb ) return 0;
+    if (ta == tb) return 0;
+    if (!tb) return -1;
+    if (!ta) return +1;
 
     if (ta->date_posted != tb->date_posted)
         return (ta->date_posted > tb->date_posted) - (ta->date_posted < tb->date_posted);

commit 655bddda46bb73647b7ababc879905339793e056
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sun Nov 2 22:32:29 2025 +0800

    [account.cpp] comparing identical accts returns 0
    
    bypassing many comparisons

diff --git a/libgnucash/engine/Account.cpp b/libgnucash/engine/Account.cpp
index 6e6f6ae2ba..da3ed89542 100644
--- a/libgnucash/engine/Account.cpp
+++ b/libgnucash/engine/Account.cpp
@@ -2359,9 +2359,9 @@ xaccAccountOrder (const Account *aa, const Account *ab)
     const char *da, *db;
     int ta, tb, result;
 
-    if ( aa && !ab ) return -1;
-    if ( !aa && ab ) return +1;
-    if ( !aa && !ab ) return 0;
+    if (aa == ab) return 0;
+    if (!ab) return -1;
+    if (!aa) return +1;
 
     priv_aa = GET_PRIVATE(aa);
     priv_ab = GET_PRIVATE(ab);

commit 001c690a811ae94fb5ba1dc0d767eee4d36eae1c
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sun Nov 2 10:20:49 2025 +0800

    [account.cpp] gnc_account_foreach_split forward loops only
    
    because the reverse iteration isn't used at all

diff --git a/bindings/engine.i b/bindings/engine.i
index bdc4d1abac..5b1d5b587c 100644
--- a/bindings/engine.i
+++ b/bindings/engine.i
@@ -168,7 +168,7 @@ SplitsVec gnc_get_match_commodity_splits (AccountVec accounts, bool use_end_date
             { gnc_account_foreach_split_until_date (acc, end_date, maybe_accumulate); };
     else
         scan_account = [maybe_accumulate](auto acc)
-            { gnc_account_foreach_split (acc, maybe_accumulate, false); };
+            { gnc_account_foreach_split (acc, maybe_accumulate); };
 
     std::for_each (accounts.begin(), accounts.end(), scan_account);
     if (sort)
diff --git a/libgnucash/engine/Account.cpp b/libgnucash/engine/Account.cpp
index 3ad3ee5150..6e6f6ae2ba 100644
--- a/libgnucash/engine/Account.cpp
+++ b/libgnucash/engine/Account.cpp
@@ -1137,17 +1137,13 @@ xaccInitAccount (Account * acc, QofBook *book)
 \********************************************************************/
 
 void
-gnc_account_foreach_split (const Account *acc, std::function<void(Split*)> func,
-                           bool reverse)
+gnc_account_foreach_split (const Account *acc, std::function<void(Split*)> func)
 {
     if (!GNC_IS_ACCOUNT (acc))
         return;
 
     auto& splits{GET_PRIVATE(acc)->splits};
-    if (reverse)
-        std::for_each(splits.rbegin(), splits.rend(), func);
-    else
-        std::for_each(splits.begin(), splits.end(), func);
+    std::for_each (splits.begin(), splits.end(), func);
 }
 
 void
@@ -5012,7 +5008,7 @@ void
 gnc_account_tree_begin_staged_transaction_traversals (Account *account)
 {
     auto do_one_account = [](auto acc)
-    { gnc_account_foreach_split (acc, [](auto s){ s->parent->marker = 0; }, false); };
+    { gnc_account_foreach_split (acc, [](auto s){ s->parent->marker = 0; }); };
     gnc_account_foreach_descendant (account, do_one_account);
 }
 
diff --git a/libgnucash/engine/Account.hpp b/libgnucash/engine/Account.hpp
index 598cd0a5df..9049cb94b7 100644
--- a/libgnucash/engine/Account.hpp
+++ b/libgnucash/engine/Account.hpp
@@ -44,7 +44,7 @@ const SplitsVec& xaccAccountGetSplits (const Account*);
 
 void gnc_account_foreach_descendant (const Account *, std::function<void(Account*)> func);
 
-void gnc_account_foreach_split (const Account*, std::function<void(Split*)>, bool);
+void gnc_account_foreach_split (const Account*, std::function<void(Split*)>);
 
 void gnc_account_foreach_split_until_date (const Account *acc, time64 end_date,
                                            std::function<void(Split*)> f);
diff --git a/libgnucash/engine/Scrub.cpp b/libgnucash/engine/Scrub.cpp
index f819ef41af..73c91ca5eb 100644
--- a/libgnucash/engine/Scrub.cpp
+++ b/libgnucash/engine/Scrub.cpp
@@ -98,7 +98,7 @@ get_all_transactions (Account *account, bool descendants)
 {
     TransSet set;
     auto add_transactions = [&set](auto a)
-    { gnc_account_foreach_split (a, [&set](auto s){ set.insert (xaccSplitGetParent (s)); }, false); };
+    { gnc_account_foreach_split (a, [&set](auto s){ set.insert (xaccSplitGetParent (s)); }); };
     add_transactions (account);
     if (descendants)
         gnc_account_foreach_descendant (account, add_transactions);



Summary of changes:
 bindings/engine.i                 |  2 +-
 libgnucash/engine/Account.cpp     | 16 ++++++----------
 libgnucash/engine/Account.hpp     |  2 +-
 libgnucash/engine/Scrub.cpp       |  2 +-
 libgnucash/engine/Transaction.cpp |  6 +++---
 5 files changed, 12 insertions(+), 16 deletions(-)



More information about the gnucash-changes mailing list