diff options
author | John Wiegley <johnw@newartisans.com> | 2010-06-13 03:54:10 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2010-06-13 03:54:10 -0400 |
commit | f3fa011d39336f9a13ad1f09016e30f88e09ba56 (patch) | |
tree | 2c68ab7d89636b5a47fd8babc01e85cfe489a28d /src/value.cc | |
parent | 0c02b720ef209a26709acfed547da84056b3aea2 (diff) | |
download | fork-ledger-f3fa011d39336f9a13ad1f09016e30f88e09ba56.tar.gz fork-ledger-f3fa011d39336f9a13ad1f09016e30f88e09ba56.tar.bz2 fork-ledger-f3fa011d39336f9a13ad1f09016e30f88e09ba56.zip |
Improved support for value_t::in_place* functions
Diffstat (limited to 'src/value.cc')
-rw-r--r-- | src/value.cc | 62 |
1 files changed, 26 insertions, 36 deletions
diff --git a/src/value.cc b/src/value.cc index 63e48333..f03b4017 100644 --- a/src/value.cc +++ b/src/value.cc @@ -1304,13 +1304,10 @@ void value_t::in_place_negate() case BALANCE: as_balance_lval().in_place_negate(); return; - case SEQUENCE: { - value_t temp; - foreach (const value_t& value, as_sequence()) - temp.push_back(- value); - *this = temp; + case SEQUENCE: + foreach (value_t& value, as_sequence_lval()) + value.in_place_negate(); return; - } default: break; } @@ -1341,13 +1338,10 @@ void value_t::in_place_not() case STRING: set_boolean(as_string().empty()); return; - case SEQUENCE: { - value_t temp; - foreach (const value_t& value, as_sequence()) - temp.push_back(! value); - *this = temp; + case SEQUENCE: + foreach (value_t& value, as_sequence_lval()) + value.in_place_not(); return; - } default: break; } @@ -1491,6 +1485,10 @@ void value_t::in_place_reduce() case BALANCE: as_balance_lval().in_place_reduce(); return; + case SEQUENCE: + foreach (value_t& value, as_sequence_lval()) + value.in_place_reduce(); + return; default: return; } @@ -1507,6 +1505,10 @@ void value_t::in_place_unreduce() case BALANCE: as_balance_lval().in_place_unreduce(); return; + case SEQUENCE: + foreach (value_t& value, as_sequence_lval()) + value.in_place_unreduce(); + return; default: return; } @@ -1547,13 +1549,10 @@ void value_t::in_place_round() case BALANCE: as_balance_lval().in_place_round(); return; - case SEQUENCE: { - value_t temp; - foreach (const value_t& value, as_sequence()) - temp.push_back(value.rounded()); - *this = temp; + case SEQUENCE: + foreach (value_t& value, as_sequence_lval()) + value.in_place_round(); return; - } default: break; } @@ -1573,13 +1572,10 @@ void value_t::in_place_truncate() case BALANCE: as_balance_lval().in_place_truncate(); return; - case SEQUENCE: { - value_t temp; - foreach (const value_t& value, as_sequence()) - temp.push_back(value.truncated()); - *this = temp; + case SEQUENCE: + foreach (value_t& value, as_sequence_lval()) + value.in_place_truncate(); return; - } default: break; } @@ -1599,13 +1595,10 @@ void value_t::in_place_floor() case BALANCE: as_balance_lval().in_place_floor(); return; - case SEQUENCE: { - value_t temp; - foreach (const value_t& value, as_sequence()) - temp.push_back(value.floored()); - *this = temp; + case SEQUENCE: + foreach (value_t& value, as_sequence_lval()) + value.in_place_floor(); return; - } default: break; } @@ -1625,13 +1618,10 @@ void value_t::in_place_unround() case BALANCE: as_balance_lval().in_place_unround(); return; - case SEQUENCE: { - value_t temp; - foreach (const value_t& value, as_sequence()) - temp.push_back(value.unrounded()); - *this = temp; + case SEQUENCE: + foreach (value_t& value, as_sequence_lval()) + value.in_place_unround(); return; - } default: break; } |