[account.cpp] gnc_account_foreach_split forward loops only

because the reverse iteration isn't used at all
pull/2146/head
Christopher Lam 7 months ago
parent 0b66ee3be0
commit 001c690a81

@ -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)

@ -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);
}

@ -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);

@ -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);

Loading…
Cancel
Save