diff options
author | John Wiegley <johnw@newartisans.com> | 2006-03-04 14:46:04 +0000 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2008-04-13 05:48:44 -0400 |
commit | 581b3d5b9a3eebdd8f396d910386cadd9426b915 (patch) | |
tree | c7493496010c811cf276a1e68d7c10bc87e7abbd /value.h | |
parent | 6375730fc9af02c27ec774aa2b9929095f5ffbde (diff) | |
download | ledger-581b3d5b9a3eebdd8f396d910386cadd9426b915.tar.gz ledger-581b3d5b9a3eebdd8f396d910386cadd9426b915.tar.bz2 ledger-581b3d5b9a3eebdd8f396d910386cadd9426b915.zip |
*** no comment ***
Diffstat (limited to 'value.h')
-rw-r--r-- | value.h | 57 |
1 files changed, 30 insertions, 27 deletions
@@ -121,40 +121,43 @@ class value_t return *this = amount_t(value); } value_t& operator=(const amount_t& value) { - if ((amount_t *) data != &value) { - if (! value) { - return *this = 0L; - } else { - destroy(); - new((amount_t *)data) amount_t(value); - type = AMOUNT; - } - } + if (type == AMOUNT && + (amount_t *) data == &value) + return *this; + + destroy(); + new((amount_t *)data) amount_t(value); + type = AMOUNT; + return *this; } value_t& operator=(const balance_t& value) { - if ((balance_t *) data != &value) { - if (value.amounts.size() == 1) { - return *this = (*value.amounts.begin()).second; - } else { - destroy(); - new((balance_t *)data) balance_t(value); - type = BALANCE; - } + if (type == BALANCE && + (balance_t *) data == &value) + return *this; + + if (value.amounts.size() == 1) { + return *this = (*value.amounts.begin()).second; + } else { + destroy(); + new((balance_t *)data) balance_t(value); + type = BALANCE; + return *this; } - return *this; } value_t& operator=(const balance_pair_t& value) { - if ((balance_pair_t *) data != &value) { - if (! value.cost) { - return *this = value.quantity; - } else { - destroy(); - new((balance_pair_t *)data) balance_pair_t(value); - type = BALANCE_PAIR; - } + if (type == BALANCE_PAIR && + (balance_pair_t *) data == &value) + return *this; + + if (! value.cost) { + return *this = value.quantity; + } else { + destroy(); + new((balance_pair_t *)data) balance_pair_t(value); + type = BALANCE_PAIR; + return *this; } - return *this; } value_t& operator+=(const value_t& value); |