gnucash stable: [Account.cpp] gnc_account_remove_split shortcuts removing last split
Christopher Lam
clam at code.gnucash.org
Sun May 26 19:05:54 EDT 2024
Updated via https://github.com/Gnucash/gnucash/commit/e80249ce (commit)
from https://github.com/Gnucash/gnucash/commit/25a5e441 (commit)
commit e80249ce2bbe90c54372e0fc5768aa0e9349f5ce
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Mon May 27 07:03:42 2024 +0800
[Account.cpp] gnc_account_remove_split shortcuts removing last split
this speeds up book shutdown which empties the account splits in
reverse chrono order.
diff --git a/libgnucash/engine/Account.cpp b/libgnucash/engine/Account.cpp
index e82fb8d9c0..94dd328681 100644
--- a/libgnucash/engine/Account.cpp
+++ b/libgnucash/engine/Account.cpp
@@ -2002,8 +2002,15 @@ gnc_account_remove_split (Account *acc, Split *s)
if (!g_hash_table_remove (priv->splits_hash, s))
return false;
- auto it = std::remove (priv->splits.begin(), priv->splits.end(), s);
- priv->splits.erase (it, priv->splits.end());
+
+ // shortcut pruning the last element. this is the most common
+ // remove_split operation during UI or book shutdown.
+ if (s == priv->splits.back())
+ priv->splits.pop_back();
+ else
+ priv->splits.erase (std::remove (priv->splits.begin(), priv->splits.end(), s),
+ priv->splits.end());
+
//FIXME: find better event type
qof_event_gen(&acc->inst, QOF_EVENT_MODIFY, nullptr);
// And send the account-based event, too
Summary of changes:
libgnucash/engine/Account.cpp | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
More information about the gnucash-changes
mailing list