Skip to content

Commit

Permalink
[transaction.cpp] use std::swap instead of SWAP macro
Browse files Browse the repository at this point in the history
  • Loading branch information
christopherlam committed Jul 9, 2024
1 parent 2250e69 commit 5f17334
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions libgnucash/engine/Transaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1618,9 +1618,6 @@ xaccTransCommitEdit (Transaction *trans)
LEAVE ("(trans=%p)", trans);
}

#define SWAP_STR(a, b) do { const char *tmp = (a); (a) = (b); (b) = tmp; } while (0);
#define SWAP(a, b) do { gpointer tmp = (a); (a) = (b); (b) = tmp; } while (0);

/* Ughhh. The Rollback function is terribly complex, and, what's worse,
* it only rolls back the basics. The TransCommit functions did a bunch
* of Lot/Cap-gains scrubbing that don't get addressed/undone here, and
Expand Down Expand Up @@ -1658,8 +1655,8 @@ xaccTransRollbackEdit (Transaction *trans)
/* copy the original values back in. */

orig = trans->orig;
SWAP_STR(trans->num, orig->num);
SWAP_STR(trans->description, orig->description);
std::swap (trans->num, orig->num);
std::swap (trans->description, orig->description);
trans->date_entered = orig->date_entered;
trans->date_posted = orig->date_posted;
std::swap (trans->common_currency, orig->common_currency);
Expand All @@ -1686,8 +1683,8 @@ xaccTransRollbackEdit (Transaction *trans)
Split *so = GNC_SPLIT(onode->data);

xaccSplitRollbackEdit(s);
SWAP_STR(s->action, so->action);
SWAP_STR(s->memo, so->memo);
std::swap (s->action, so->action);
std::swap (s->memo, so->memo);
qof_instance_copy_kvp (QOF_INSTANCE (s), QOF_INSTANCE (so));
s->reconciled = so->reconciled;
s->amount = so->amount;
Expand Down

0 comments on commit 5f17334

Please sign in to comment.