summaryrefslogtreecommitdiff
path: root/binary.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2004-08-21 15:55:03 -0400
committerJohn Wiegley <johnw@newartisans.com>2004-08-21 15:55:03 -0400
commit000bfe1cece3ecbfee8f07a46d1f0b000dbbc983 (patch)
tree6d2c666097900fff421da6a57b41f0a7c43a39b7 /binary.cc
parent225acd14e57a0a476ce022a7c5703a8f1cee34ef (diff)
downloadfork-ledger-000bfe1cece3ecbfee8f07a46d1f0b000dbbc983.tar.gz
fork-ledger-000bfe1cece3ecbfee8f07a46d1f0b000dbbc983.tar.bz2
fork-ledger-000bfe1cece3ecbfee8f07a46d1f0b000dbbc983.zip
only compute the cost when it differs from the amount
Diffstat (limited to 'binary.cc')
-rw-r--r--binary.cc14
1 files changed, 11 insertions, 3 deletions
diff --git a/binary.cc b/binary.cc
index 3d665244..4fb557a5 100644
--- a/binary.cc
+++ b/binary.cc
@@ -9,7 +9,7 @@
namespace ledger {
const unsigned long binary_magic_number = 0xFFEED765;
-static const unsigned long format_version = 0x0002000e;
+static const unsigned long format_version = 0x00020010;
bool binary_parser_t::test(std::istream& in) const
{
@@ -102,7 +102,10 @@ transaction_t * read_binary_transaction(std::istream& in, entry_t * entry)
xact->account->add_transaction(xact);
read_binary_amount(in, xact->amount);
- read_binary_amount(in, xact->cost);
+ if (read_binary_number<char>(in) == 1) {
+ xact->cost = new amount_t;
+ read_binary_amount(in, *xact->cost);
+ }
read_binary_number(in, xact->flags);
read_binary_string(in, xact->note);
@@ -314,7 +317,12 @@ void write_binary_transaction(std::ostream& out, transaction_t * xact)
{
write_binary_number(out, xact->account->ident);
write_binary_amount(out, xact->amount);
- write_binary_amount(out, xact->cost);
+ if (xact->cost) {
+ write_binary_number<char>(out, 1);
+ write_binary_amount(out, *xact->cost);
+ } else {
+ write_binary_number<char>(out, 0);
+ }
write_binary_number(out, xact->flags);
write_binary_string(out, xact->note);
}