summaryrefslogtreecommitdiff
path: root/amount.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2004-11-15 12:46:23 +0000
committerJohn Wiegley <johnw@newartisans.com>2008-04-13 02:40:48 -0400
commitb4cdc528b42e0c8c6b2a9ad5c5a3dab2dd682653 (patch)
tree7791f5df63f281ef8911ca89df5f75da04ee0f71 /amount.cc
parent695c2d6e28abf6ea06e64d61dafec90198d9097a (diff)
downloadfork-ledger-b4cdc528b42e0c8c6b2a9ad5c5a3dab2dd682653.tar.gz
fork-ledger-b4cdc528b42e0c8c6b2a9ad5c5a3dab2dd682653.tar.bz2
fork-ledger-b4cdc528b42e0c8c6b2a9ad5c5a3dab2dd682653.zip
*** empty log message ***
Diffstat (limited to 'amount.cc')
-rw-r--r--amount.cc22
1 files changed, 10 insertions, 12 deletions
diff --git a/amount.cc b/amount.cc
index d0c9f6a8..4d95b3bd 100644
--- a/amount.cc
+++ b/amount.cc
@@ -1141,21 +1141,19 @@ amount_t commodity_t::value(const std::time_t moment)
std::time_t age = 0;
amount_t price;
- if (! history)
- return price;
-
- for (history_map::reverse_iterator i = history->prices.rbegin();
- i != history->prices.rend();
- i++)
- if (moment == 0 || std::difftime(moment, (*i).first) >= 0) {
- age = (*i).first;
- price = (*i).second;
- break;
- }
+ if (history)
+ for (history_map::reverse_iterator i = history->prices.rbegin();
+ i != history->prices.rend();
+ i++)
+ if (moment == 0 || std::difftime(moment, (*i).first) >= 0) {
+ age = (*i).first;
+ price = (*i).second;
+ break;
+ }
if (updater)
(*updater)(*this, moment, age,
- (history->prices.size() > 0 ?
+ (history && history->prices.size() > 0 ?
(*history->prices.rbegin()).first : 0), price);
return price;