diff options
author | John Wiegley <johnw@newartisans.com> | 2012-03-06 23:05:06 -0600 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2012-03-06 23:05:06 -0600 |
commit | 17782c9cfea390782096bd8b1c8765c23182756e (patch) | |
tree | ea645d789b49097369f5f132447f82c728b13ded /src/history.h | |
parent | 75603edeb4853b1e563f525bcc3482609853a975 (diff) | |
download | fork-ledger-17782c9cfea390782096bd8b1c8765c23182756e.tar.gz fork-ledger-17782c9cfea390782096bd8b1c8765c23182756e.tar.bz2 fork-ledger-17782c9cfea390782096bd8b1c8765c23182756e.zip |
Simplified commodity_history_t
Diffstat (limited to 'src/history.h')
-rw-r--r-- | src/history.h | 52 |
1 files changed, 16 insertions, 36 deletions
diff --git a/src/history.h b/src/history.h index fc984c1b..16d552ab 100644 --- a/src/history.h +++ b/src/history.h @@ -70,39 +70,25 @@ public: PricePointMap price_point; PriceRatioMap ratios; - datetime_t * reftime; - optional<datetime_t> * last_reftime; - optional<datetime_t> * oldest; - optional<datetime_t> * last_oldest; + datetime_t reftime; + optional<datetime_t> oldest; recent_edge_weight() { } - recent_edge_weight(EdgeWeightMap _weight, - PricePointMap _price_point, - PriceRatioMap _ratios, - datetime_t * _reftime, - optional<datetime_t> * _last_reftime, - optional<datetime_t> * _oldest, - optional<datetime_t> * _last_oldest) + recent_edge_weight(EdgeWeightMap _weight, + PricePointMap _price_point, + PriceRatioMap _ratios, + datetime_t _reftime, + const optional<datetime_t>& _oldest = none) : weight(_weight), price_point(_price_point), ratios(_ratios), - reftime(_reftime), last_reftime(_last_reftime), - oldest(_oldest), last_oldest(_last_oldest) { } + reftime(_reftime), oldest(_oldest) { } template <typename Edge> bool operator()(const Edge& e) const { - DEBUG("history.find", " reftime = " << *reftime); - if (*last_reftime) - DEBUG("history.find", " last_reftime = " << **last_reftime); - if (*oldest) - DEBUG("history.find", " oldest = " << **oldest); - if (*last_oldest) - DEBUG("history.find", " last_oldest = " << **last_oldest); - -#if 0 - if (*last_reftime && *reftime == **last_reftime && - *oldest == *last_oldest) { - DEBUG("history.find", " using previous reftime"); - return get(weight, e) != std::numeric_limits<std::size_t>::max(); +#if defined(DEBUG_ON) + DEBUG("history.find", " reftime = " << reftime); + if (oldest) { + DEBUG("history.find", " oldest = " << *oldest); } #endif @@ -113,22 +99,22 @@ public: return false; } - price_map_t::const_iterator low = prices.upper_bound(*reftime); + price_map_t::const_iterator low = prices.upper_bound(reftime); if (low != prices.end() && low == prices.begin()) { DEBUG("history.find", " don't use this edge"); put(weight, e, std::numeric_limits<std::size_t>::max()); return false; } else { --low; - assert(((*low).first <= *reftime)); + assert(((*low).first <= reftime)); - if (*oldest && (*low).first < **oldest) { + if (oldest && (*low).first < *oldest) { DEBUG("history.find", " edge is out of range"); put(weight, e, std::numeric_limits<std::size_t>::max()); return false; } - long secs = (*reftime - (*low).first).total_seconds(); + long secs = (reftime - (*low).first).total_seconds(); assert(secs >= 0); put(weight, e, secs); @@ -191,12 +177,6 @@ public: PriceRatioMap> > FGraph; typedef property_map<FGraph, vertex_name_t>::type FNameMap; - // jww (2012-03-05): Prevents threading - mutable datetime_t reftime; - mutable optional<datetime_t> last_reftime; - mutable optional<datetime_t> oldest; - mutable optional<datetime_t> last_oldest; - commodity_history_t() : indexmap(get(vertex_index, price_graph)), pricemap(get(edge_price_point, price_graph)), |