Skip to content

Commit

Permalink
[account.cpp] gnc_account_remove_split searches from the end
Browse files Browse the repository at this point in the history
because removing the latest split is far more common (e.g. from ui or
during book shutdown) than removing an early split.
  • Loading branch information
christopherlam committed May 21, 2024
1 parent 2d030c5 commit 5aff4fb
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions libgnucash/engine/Account.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2002,8 +2002,11 @@ 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());

// search splits in reverse, because removing the latest split is
// more common (e.g. from UI or during book shutdown)
auto rit = std::remove(priv->splits.rbegin(), priv->splits.rend(), s);
priv->splits.erase(rit.base(), priv->splits.end());
//FIXME: find better event type
qof_event_gen(&acc->inst, QOF_EVENT_MODIFY, nullptr);
// And send the account-based event, too
Expand Down

1 comment on commit 5aff4fb

@christopherlam
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this improves my book shutdown times from 0.64s to 0.33s (or, before #1941, from 0.9s to 0.33s)

Please sign in to comment.