diff options
author | John Wiegley <johnw@newartisans.com> | 2009-01-23 19:50:35 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2009-01-23 19:50:35 -0400 |
commit | c49f05a15a86006a8ee41d721415282c1b8be744 (patch) | |
tree | 5ac8195e5911fad9e877c553104b08f7ea42d018 /src | |
parent | 784ec4b787dfca020f2fe1800d8724a6ee705e04 (diff) | |
download | fork-ledger-c49f05a15a86006a8ee41d721415282c1b8be744.tar.gz fork-ledger-c49f05a15a86006a8ee41d721415282c1b8be744.tar.bz2 fork-ledger-c49f05a15a86006a8ee41d721415282c1b8be744.zip |
Guard debug code in commodity.cc, so it will build optimized.
Diffstat (limited to 'src')
-rw-r--r-- | src/commodity.cc | 44 |
1 files changed, 42 insertions, 2 deletions
diff --git a/src/commodity.cc b/src/commodity.cc index 02aa5e81..d674833c 100644 --- a/src/commodity.cc +++ b/src/commodity.cc @@ -142,8 +142,10 @@ optional<price_point_t> #endif if (prices.size() == 0) { +#if defined(DEBUG_ON) DEBUG_INDENT("commodity.prices", indent); DEBUG("commodity.prices", " there are no prices in this history"); +#endif return none; } @@ -152,8 +154,10 @@ optional<price_point_t> point.when = (*r).first; point.price = (*r).second; found = true; +#if defined(DEBUG_ON) DEBUG_INDENT("commodity.prices", indent); DEBUG("commodity.prices", " using most recent price"); +#endif } else { history_map::const_iterator i = prices.lower_bound(*moment); if (i == prices.end()) { @@ -161,8 +165,10 @@ optional<price_point_t> point.when = (*r).first; point.price = (*r).second; found = true; +#if defined(DEBUG_ON) DEBUG_INDENT("commodity.prices", indent); DEBUG("commodity.prices", " using last price"); +#endif } else { point.when = (*i).first; if (*moment < point.when) { @@ -176,8 +182,10 @@ optional<price_point_t> point.price = (*i).second; found = true; } +#if defined(DEBUG_ON) DEBUG_INDENT("commodity.prices", indent); DEBUG("commodity.prices", " using found price"); +#endif } } @@ -192,24 +200,32 @@ optional<price_point_t> #endif if (! found) { +#if defined(DEBUG_ON) DEBUG_INDENT("commodity.prices", indent); DEBUG("commodity.prices", " could not find a price"); +#endif return none; } else if (moment && point.when > *moment) { +#if defined(DEBUG_ON) DEBUG_INDENT("commodity.prices", indent); DEBUG("commodity.prices", " price is too young "); +#endif return none; } else if (oldest && point.when < *oldest) { +#if defined(DEBUG_ON) DEBUG_INDENT("commodity.prices", indent); DEBUG("commodity.prices", " price is too old "); +#endif return none; } else { +#if defined(DEBUG_ON) DEBUG_INDENT("commodity.prices", indent); DEBUG("commodity.prices", " returning price: " << point.when << ", " << point.price); +#endif return point; } } @@ -263,59 +279,83 @@ optional<price_point_t> if (comm == source) continue; +#if defined(DEBUG_ON) DEBUG_INDENT("commodity.prices", indent + 1); DEBUG("commodity.prices", " searching for price via commodity '" << comm << "'"); +#endif - point = hist.second.find_price(source, commodity, moment, limit, indent + 2); + point = hist.second.find_price(source, commodity, moment, limit +#if defined(DEBUG_ON) + , indent + 2 +#endif + ); assert(! point || point->price.commodity() == comm); if (point) { optional<price_point_t> xlat; if (commodity && comm != *commodity) { +#if defined(DEBUG_ON) DEBUG_INDENT("commodity.prices", indent + 1); DEBUG("commodity.prices", " looking for translation price"); +#endif - xlat = comm.find_price(commodity, moment, limit, indent + 2); + xlat = comm.find_price(commodity, moment, limit +#if defined(DEBUG_ON) + , indent + 2 +#endif + ); if (xlat) { +#if defined(DEBUG_ON) DEBUG_INDENT("commodity.prices", indent + 1); DEBUG("commodity.prices", " found translated price " << xlat->price << " from " << xlat->when); +#endif point->price = xlat->price * point->price; if (xlat->when < point->when) { point->when = xlat->when; +#if defined(DEBUG_ON) DEBUG_INDENT("commodity.prices", indent + 1); DEBUG("commodity.prices", " adjusting date of result back to " << point->when); +#endif } } else { +#if defined(DEBUG_ON) DEBUG_INDENT("commodity.prices", indent + 1); DEBUG("commodity.prices", " saw no translated price there"); +#endif continue; } } assert(! commodity || point->price.commodity() == *commodity); +#if defined(DEBUG_ON) DEBUG_INDENT("commodity.prices", indent + 1); DEBUG("commodity.prices", " saw a price there: " << point->price << " from " << point->when); +#endif if (! limit || point->when > *limit) { limit = point->when; best = *point; found = true; } } else { +#if defined(DEBUG_ON) DEBUG_INDENT("commodity.prices", indent + 1); DEBUG("commodity.prices", " saw no price there"); +#endif } } if (found) { +#if defined(DEBUG_ON) DEBUG_INDENT("commodity.prices", indent); DEBUG("commodity.prices", " found price " << best.price << " from " << best.when); +#endif return best; } return none; |