From 9f53efbf5f8e49b9c4dbe8c3ff595e99903b3aab Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Mon, 23 Feb 2009 01:51:23 -0400 Subject: Many fixes to both --market and --exchange --- src/balance.cc | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'src/balance.cc') diff --git a/src/balance.cc b/src/balance.cc index 70e83362..39392aa3 100644 --- a/src/balance.cc +++ b/src/balance.cc @@ -163,18 +163,19 @@ balance_t::value(const bool primary_only, const optional& moment, const optional& in_terms_of) const { - optional temp; + balance_t temp; + bool resolved = false; foreach (const amounts_map::value_type& pair, amounts) { - if (! temp) - temp = balance_t(); if (optional val = pair.second.value(primary_only, moment, - in_terms_of)) - *temp += *val; - else - *temp += pair.second; + in_terms_of)) { + temp += *val; + resolved = true; + } else { + temp += pair.second; + } } - return temp; + return resolved ? temp : optional(); } optional -- cgit v1.2.3