Skip to content

Commit 001c690

Browse files
[account.cpp] gnc_account_foreach_split forward loops only
because the reverse iteration isn't used at all
1 parent 0b66ee3 commit 001c690

File tree

4 files changed

+6
-10
lines changed

4 files changed

+6
-10
lines changed

bindings/engine.i

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ SplitsVec gnc_get_match_commodity_splits (AccountVec accounts, bool use_end_date
168168
{ gnc_account_foreach_split_until_date (acc, end_date, maybe_accumulate); };
169169
else
170170
scan_account = [maybe_accumulate](auto acc)
171-
{ gnc_account_foreach_split (acc, maybe_accumulate, false); };
171+
{ gnc_account_foreach_split (acc, maybe_accumulate); };
172172

173173
std::for_each (accounts.begin(), accounts.end(), scan_account);
174174
if (sort)

libgnucash/engine/Account.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1137,17 +1137,13 @@ xaccInitAccount (Account * acc, QofBook *book)
11371137
\********************************************************************/
11381138

11391139
void
1140-
gnc_account_foreach_split (const Account *acc, std::function<void(Split*)> func,
1141-
bool reverse)
1140+
gnc_account_foreach_split (const Account *acc, std::function<void(Split*)> func)
11421141
{
11431142
if (!GNC_IS_ACCOUNT (acc))
11441143
return;
11451144

11461145
auto& splits{GET_PRIVATE(acc)->splits};
1147-
if (reverse)
1148-
std::for_each(splits.rbegin(), splits.rend(), func);
1149-
else
1150-
std::for_each(splits.begin(), splits.end(), func);
1146+
std::for_each (splits.begin(), splits.end(), func);
11511147
}
11521148

11531149
void
@@ -5012,7 +5008,7 @@ void
50125008
gnc_account_tree_begin_staged_transaction_traversals (Account *account)
50135009
{
50145010
auto do_one_account = [](auto acc)
5015-
{ gnc_account_foreach_split (acc, [](auto s){ s->parent->marker = 0; }, false); };
5011+
{ gnc_account_foreach_split (acc, [](auto s){ s->parent->marker = 0; }); };
50165012
gnc_account_foreach_descendant (account, do_one_account);
50175013
}
50185014

libgnucash/engine/Account.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const SplitsVec& xaccAccountGetSplits (const Account*);
4444

4545
void gnc_account_foreach_descendant (const Account *, std::function<void(Account*)> func);
4646

47-
void gnc_account_foreach_split (const Account*, std::function<void(Split*)>, bool);
47+
void gnc_account_foreach_split (const Account*, std::function<void(Split*)>);
4848

4949
void gnc_account_foreach_split_until_date (const Account *acc, time64 end_date,
5050
std::function<void(Split*)> f);

libgnucash/engine/Scrub.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ get_all_transactions (Account *account, bool descendants)
9898
{
9999
TransSet set;
100100
auto add_transactions = [&set](auto a)
101-
{ gnc_account_foreach_split (a, [&set](auto s){ set.insert (xaccSplitGetParent (s)); }, false); };
101+
{ gnc_account_foreach_split (a, [&set](auto s){ set.insert (xaccSplitGetParent (s)); }); };
102102
add_transactions (account);
103103
if (descendants)
104104
gnc_account_foreach_descendant (account, add_transactions);

0 commit comments

Comments
 (0)