summaryrefslogtreecommitdiff
path: root/src/amount.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2012-03-11 03:55:25 -0500
committerJohn Wiegley <johnw@newartisans.com>2012-03-11 03:55:25 -0500
commit363670d35bf451ff8ce636c071da73a0d93c514a (patch)
tree153899e85596849bcbe96c820d5d55bbc61f1d8b /src/amount.cc
parent2303aa993cf41ad5bde8f8f5722bd265c11e3aa7 (diff)
downloadfork-ledger-363670d35bf451ff8ce636c071da73a0d93c514a.tar.gz
fork-ledger-363670d35bf451ff8ce636c071da73a0d93c514a.tar.bz2
fork-ledger-363670d35bf451ff8ce636c071da73a0d93c514a.zip
Tighten up argument passing related to fn_market()
Diffstat (limited to 'src/amount.cc')
-rw-r--r--src/amount.cc19
1 files changed, 7 insertions, 12 deletions
diff --git a/src/amount.cc b/src/amount.cc
index 46eb5531..5fa58528 100644
--- a/src/amount.cc
+++ b/src/amount.cc
@@ -728,16 +728,16 @@ void amount_t::in_place_unreduce()
}
optional<amount_t>
-amount_t::value(const optional<datetime_t>& moment,
- const optional<commodity_t&>& in_terms_of) const
+amount_t::value(const datetime_t& moment,
+ const commodity_t * in_terms_of) const
{
if (quantity) {
#if defined(DEBUG_ON)
DEBUG("commodity.price.find",
"amount_t::value of " << commodity().symbol());
- if (moment)
+ if (! moment.is_not_a_date_time())
DEBUG("commodity.price.find",
- "amount_t::value: moment = " << *moment);
+ "amount_t::value: moment = " << moment);
if (in_terms_of)
DEBUG("commodity.price.find",
"amount_t::value: in_terms_of = " << in_terms_of->symbol());
@@ -745,7 +745,7 @@ amount_t::value(const optional<datetime_t>& moment,
if (has_commodity() &&
(in_terms_of || ! commodity().has_flags(COMMODITY_PRIMARY))) {
optional<price_point_t> point;
- optional<commodity_t&> comm(in_terms_of);
+ const commodity_t * comm(in_terms_of);
if (has_annotation() && annotation().price) {
if (annotation().has_flags(ANNOTATION_PRICE_FIXATED)) {
@@ -755,7 +755,7 @@ amount_t::value(const optional<datetime_t>& moment,
"amount_t::value: fixated price = " << point->price);
}
else if (! comm) {
- comm = annotation().price->commodity();
+ comm = annotation().price->commodity_ptr();
}
}
@@ -869,15 +869,10 @@ bool amount_t::fits_in_long() const
commodity_t * amount_t::commodity_ptr() const
{
- return (has_commodity() ?
+ return (commodity_ ?
commodity_ : commodity_pool_t::current_pool->null_commodity);
}
-commodity_t& amount_t::commodity() const
-{
- return *commodity_ptr();
-}
-
bool amount_t::has_commodity() const
{
return commodity_ && commodity_ != commodity_->pool().null_commodity;