Use Boost.Tuple
This commit is contained in:
parent
b0cf90ab50
commit
628875b33c
3 changed files with 14 additions and 13 deletions
|
|
@ -129,16 +129,16 @@ commodity_t::find_price(const optional<commodity_t&>& commodity,
|
||||||
if (target && *this == *target)
|
if (target && *this == *target)
|
||||||
return none;
|
return none;
|
||||||
|
|
||||||
optional<base_t::time_and_commodity_t> pair =
|
optional<base_t::memoized_price_entry>
|
||||||
base_t::time_and_commodity_t(base_t::optional_time_pair_t(moment, oldest),
|
entry(base_t::memoized_price_entry(moment, oldest,
|
||||||
commodity ? &(*commodity) : NULL);
|
commodity ? &(*commodity) : NULL));
|
||||||
|
|
||||||
DEBUG("commodity.price.find", "looking for memoized args: "
|
DEBUG("commodity.price.find", "looking for memoized args: "
|
||||||
<< (moment ? format_datetime(*moment) : "NONE") << ", "
|
<< (moment ? format_datetime(*moment) : "NONE") << ", "
|
||||||
<< (oldest ? format_datetime(*oldest) : "NONE") << ", "
|
<< (oldest ? format_datetime(*oldest) : "NONE") << ", "
|
||||||
<< (commodity ? commodity->symbol() : "NONE"));
|
<< (commodity ? commodity->symbol() : "NONE"));
|
||||||
{
|
{
|
||||||
base_t::memoized_price_map::iterator i = base->price_map.find(*pair);
|
base_t::memoized_price_map::iterator i = base->price_map.find(*entry);
|
||||||
if (i != base->price_map.end()) {
|
if (i != base->price_map.end()) {
|
||||||
DEBUG("commodity.price.find", "found! returning: "
|
DEBUG("commodity.price.find", "found! returning: "
|
||||||
<< ((*i).second ? (*i).second->price : amount_t(0L)));
|
<< ((*i).second ? (*i).second->price : amount_t(0L)));
|
||||||
|
|
@ -162,7 +162,7 @@ commodity_t::find_price(const optional<commodity_t&>& commodity,
|
||||||
pool().commodity_price_history.find_price(*this, *target, when, oldest) :
|
pool().commodity_price_history.find_price(*this, *target, when, oldest) :
|
||||||
pool().commodity_price_history.find_price(*this, when, oldest);
|
pool().commodity_price_history.find_price(*this, when, oldest);
|
||||||
|
|
||||||
if (pair) {
|
if (entry) {
|
||||||
if (base->price_map.size() > base_t::max_price_map_size) {
|
if (base->price_map.size() > base_t::max_price_map_size) {
|
||||||
DEBUG("history.find",
|
DEBUG("history.find",
|
||||||
"price map has grown too large, clearing it by half");
|
"price map has grown too large, clearing it by half");
|
||||||
|
|
@ -172,9 +172,9 @@ commodity_t::find_price(const optional<commodity_t&>& commodity,
|
||||||
|
|
||||||
DEBUG("history.find",
|
DEBUG("history.find",
|
||||||
"remembered: " << (point ? point->price : amount_t(0L)));
|
"remembered: " << (point ? point->price : amount_t(0L)));
|
||||||
base->price_map.insert
|
base->price_map.insert(base_t::memoized_price_map::value_type(*entry, point));
|
||||||
(base_t::memoized_price_map::value_type(*pair, point));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return point;
|
return point;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -117,11 +117,9 @@ protected:
|
||||||
optional<amount_t> larger;
|
optional<amount_t> larger;
|
||||||
optional<expr_t> value_expr;
|
optional<expr_t> value_expr;
|
||||||
|
|
||||||
typedef std::pair<optional<datetime_t>,
|
typedef tuple<optional<datetime_t>,
|
||||||
optional<datetime_t> > optional_time_pair_t;
|
optional<datetime_t>, commodity_t *> memoized_price_entry;
|
||||||
typedef std::pair<optional_time_pair_t,
|
typedef std::map<memoized_price_entry,
|
||||||
commodity_t *> time_and_commodity_t;
|
|
||||||
typedef std::map<time_and_commodity_t,
|
|
||||||
optional<price_point_t> > memoized_price_map;
|
optional<price_point_t> > memoized_price_map;
|
||||||
|
|
||||||
static const std::size_t max_price_map_size = 16;
|
static const std::size_t max_price_map_size = 16;
|
||||||
|
|
|
||||||
|
|
@ -183,8 +183,11 @@ typedef std::ostream::pos_type ostream_pos_type;
|
||||||
#include <boost/regex/icu.hpp>
|
#include <boost/regex/icu.hpp>
|
||||||
#else
|
#else
|
||||||
#include <boost/regex.hpp>
|
#include <boost/regex.hpp>
|
||||||
|
|
||||||
#endif // HAVE_BOOST_REGEX_UNICODE
|
#endif // HAVE_BOOST_REGEX_UNICODE
|
||||||
|
|
||||||
|
#include <boost/tuple/tuple.hpp>
|
||||||
|
#include <boost/tuple/tuple_comparison.hpp>
|
||||||
|
|
||||||
#include <boost/variant.hpp>
|
#include <boost/variant.hpp>
|
||||||
#include <boost/version.hpp>
|
#include <boost/version.hpp>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue