gnucash stable: Multiple changes pushed

Christopher Lam clam at code.gnucash.org
Mon Jun 17 20:41:24 EDT 2024


Updated	 via  https://github.com/Gnucash/gnucash/commit/f19e4620 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/cd097d19 (commit)
	from  https://github.com/Gnucash/gnucash/commit/a210931d (commit)



commit f19e462098535e31408516985d2abcfe0a1c560e
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Tue Jun 18 08:26:48 2024 +0800

    [assistant-stock-transaction.cpp] don't copy SplitsVec

diff --git a/gnucash/gnome/assistant-stock-transaction.cpp b/gnucash/gnome/assistant-stock-transaction.cpp
index 5f7de1d349..05ddf978b6 100644
--- a/gnucash/gnome/assistant-stock-transaction.cpp
+++ b/gnucash/gnome/assistant-stock-transaction.cpp
@@ -1263,7 +1263,7 @@ StockAssistantModel::set_txn_type (guint type_idx)
 };
 
 static void
-check_txn_date(Split* last_split, time64 txn_date, Logger& logger)
+check_txn_date(const Split* last_split, time64 txn_date, Logger& logger)
 {
     auto last_split_date = xaccTransGetDate(xaccSplitGetParent(last_split));
     if (txn_date <= last_split_date) {
@@ -1301,8 +1301,7 @@ StockAssistantModel::generate_list_of_splits() {
     // transactions dated after the date specified, it is very likely
     // the later stock transactions will be invalidated. warn the user
     // to review them.
-    auto splits{xaccAccountGetSplits (m_acct)};
-    if (!splits.empty())
+    if (const auto& splits = xaccAccountGetSplits (m_acct); !splits.empty())
         check_txn_date(splits.back(), m_transaction_date, m_logger);
 
     if (m_stock_entry->enabled()  || m_stock_entry->has_amount())

commit cd097d19ec7c9e32393f3be69ad7a71e4633d74d
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Tue Jun 18 08:24:17 2024 +0800

    [Account.cpp] don't copy SplitsVec

diff --git a/libgnucash/engine/Account.cpp b/libgnucash/engine/Account.cpp
index 94dd328681..462a4be51f 100644
--- a/libgnucash/engine/Account.cpp
+++ b/libgnucash/engine/Account.cpp
@@ -1145,7 +1145,7 @@ gnc_account_foreach_split (const Account *acc, std::function<void(Split*)> func,
     if (!GNC_IS_ACCOUNT (acc))
         return;
 
-    auto splits{GET_PRIVATE(acc)->splits};
+    auto& splits{GET_PRIVATE(acc)->splits};
     if (reverse)
         std::for_each(splits.rbegin(), splits.rend(), func);
     else
@@ -1162,7 +1162,7 @@ gnc_account_foreach_split_until_date (const Account *acc, time64 end_date,
     auto after_date = [](time64 end_date, auto s) -> bool
     { return (xaccTransGetDate (xaccSplitGetParent (s)) > end_date); };
 
-    auto splits{GET_PRIVATE(acc)->splits};
+    auto& splits{GET_PRIVATE(acc)->splits};
     auto after_date_iter = std::upper_bound (splits.begin(), splits.end(), end_date, after_date);
     std::for_each (splits.begin(), after_date_iter, f);
 }
@@ -1175,7 +1175,7 @@ gnc_account_find_split (const Account *acc, std::function<bool(const Split*)> pr
     if (!GNC_IS_ACCOUNT (acc))
         return nullptr;
 
-    auto splits{GET_PRIVATE(acc)->splits};
+    const auto& splits{GET_PRIVATE(acc)->splits};
     if (reverse)
     {
         auto latest = std::find_if(splits.rbegin(), splits.rend(), predicate);
@@ -5550,7 +5550,7 @@ xaccAccountStagedTransactionTraversal (const Account *acc,
 {
     if (!acc) return 0;
 
-    auto splits = GET_PRIVATE(acc)->splits;
+    auto& splits = GET_PRIVATE(acc)->splits;
     for (auto s : splits)
     {
         auto trans = s->parent;



Summary of changes:
 gnucash/gnome/assistant-stock-transaction.cpp | 5 ++---
 libgnucash/engine/Account.cpp                 | 8 ++++----
 2 files changed, 6 insertions(+), 7 deletions(-)



More information about the gnucash-changes mailing list