Don't store the amount expression object in transactions.
This is unnecessary since binary caching is no longer being used.
This commit is contained in:
parent
bee8e50166
commit
2e9c14ef30
2 changed files with 33 additions and 5 deletions
|
|
@ -97,10 +97,15 @@ std::size_t textual_parser_t::parse(std::istream& in,
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
optional<expr_t> parse_amount_expr(std::istream& in,
|
#if defined(STORE_XACT_EXPRS)
|
||||||
amount_t& amount,
|
optional<expr_t>
|
||||||
xact_t * xact,
|
#else
|
||||||
uint_least8_t flags = 0)
|
void
|
||||||
|
#endif
|
||||||
|
parse_amount_expr(std::istream& in,
|
||||||
|
amount_t& amount,
|
||||||
|
xact_t * xact,
|
||||||
|
uint_least8_t flags = 0)
|
||||||
{
|
{
|
||||||
expr_t expr(in, flags | static_cast<uint_least8_t>(expr_t::PARSE_PARTIAL));
|
expr_t expr(in, flags | static_cast<uint_least8_t>(expr_t::PARSE_PARTIAL));
|
||||||
|
|
||||||
|
|
@ -122,9 +127,13 @@ namespace {
|
||||||
|
|
||||||
amount = result.as_amount();
|
amount = result.as_amount();
|
||||||
DEBUG("textual.parse", "The transaction amount is " << amount);
|
DEBUG("textual.parse", "The transaction amount is " << amount);
|
||||||
|
#if defined(STORE_XACT_EXPRS)
|
||||||
return expr;
|
return expr;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
#if defined(STORE_XACT_EXPRS)
|
||||||
return none;
|
return none;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -759,12 +768,16 @@ xact_t * textual_parser_t::instance_t::parse_xact(char * line,
|
||||||
|
|
||||||
if (p != '(') { // indicates a value expression
|
if (p != '(') { // indicates a value expression
|
||||||
xact->amount.parse(in, amount_t::PARSE_NO_REDUCE);
|
xact->amount.parse(in, amount_t::PARSE_NO_REDUCE);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
|
#if defined(STORE_XACT_EXPRS)
|
||||||
xact->amount_expr =
|
xact->amount_expr =
|
||||||
|
#endif
|
||||||
parse_amount_expr(in, xact->amount, xact.get(),
|
parse_amount_expr(in, xact->amount, xact.get(),
|
||||||
static_cast<uint_least8_t>(expr_t::PARSE_NO_REDUCE) |
|
static_cast<uint_least8_t>(expr_t::PARSE_NO_REDUCE) |
|
||||||
static_cast<uint_least8_t>(expr_t::PARSE_NO_ASSIGN));
|
static_cast<uint_least8_t>(expr_t::PARSE_NO_ASSIGN));
|
||||||
|
|
||||||
|
#if defined(STORE_XACT_EXPRS)
|
||||||
// We don't need to store the actual expression that resulted in the
|
// We don't need to store the actual expression that resulted in the
|
||||||
// amount if it's constant
|
// amount if it's constant
|
||||||
if (xact->amount_expr) {
|
if (xact->amount_expr) {
|
||||||
|
|
@ -774,6 +787,7 @@ xact_t * textual_parser_t::instance_t::parse_xact(char * line,
|
||||||
end = in.tellg();
|
end = in.tellg();
|
||||||
xact->amount_expr->set_text(string(line, long(beg), long(end - beg)));
|
xact->amount_expr->set_text(string(line, long(beg), long(end - beg)));
|
||||||
}
|
}
|
||||||
|
#endif // STORE_XACT_EXPRS
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! xact->amount.is_null()) {
|
if (! xact->amount.is_null()) {
|
||||||
|
|
@ -810,11 +824,14 @@ xact_t * textual_parser_t::instance_t::parse_xact(char * line,
|
||||||
if (p != '(') { // indicates a value expression
|
if (p != '(') { // indicates a value expression
|
||||||
xact->cost->parse(in, amount_t::PARSE_NO_MIGRATE);
|
xact->cost->parse(in, amount_t::PARSE_NO_MIGRATE);
|
||||||
} else {
|
} else {
|
||||||
|
#if defined(STORE_XACT_EXPRS)
|
||||||
xact->cost_expr =
|
xact->cost_expr =
|
||||||
|
#endif
|
||||||
parse_amount_expr(in, *xact->cost, xact.get(),
|
parse_amount_expr(in, *xact->cost, xact.get(),
|
||||||
static_cast<uint_least8_t>(expr_t::PARSE_NO_MIGRATE) |
|
static_cast<uint_least8_t>(expr_t::PARSE_NO_MIGRATE) |
|
||||||
static_cast<uint_least8_t>(expr_t::PARSE_NO_ASSIGN));
|
static_cast<uint_least8_t>(expr_t::PARSE_NO_ASSIGN));
|
||||||
|
|
||||||
|
#if defined(STORE_XACT_EXPRS)
|
||||||
if (xact->cost_expr) {
|
if (xact->cost_expr) {
|
||||||
end = in.tellg();
|
end = in.tellg();
|
||||||
if (per_unit)
|
if (per_unit)
|
||||||
|
|
@ -824,6 +841,7 @@ xact_t * textual_parser_t::instance_t::parse_xact(char * line,
|
||||||
xact->cost_expr->set_text(string("@@") +
|
xact->cost_expr->set_text(string("@@") +
|
||||||
string(line, long(beg), long(end - beg)));
|
string(line, long(beg), long(end - beg)));
|
||||||
}
|
}
|
||||||
|
#endif // STORE_XACT_EXPRS
|
||||||
}
|
}
|
||||||
|
|
||||||
if (xact->cost->sign() < 0)
|
if (xact->cost->sign() < 0)
|
||||||
|
|
@ -866,15 +884,19 @@ xact_t * textual_parser_t::instance_t::parse_xact(char * line,
|
||||||
if (p != '(') { // indicates a value expression
|
if (p != '(') { // indicates a value expression
|
||||||
xact->assigned_amount->parse(in, amount_t::PARSE_NO_MIGRATE);
|
xact->assigned_amount->parse(in, amount_t::PARSE_NO_MIGRATE);
|
||||||
} else {
|
} else {
|
||||||
|
#if defined(STORE_XACT_EXPRS)
|
||||||
xact->assigned_amount_expr =
|
xact->assigned_amount_expr =
|
||||||
|
#endif
|
||||||
parse_amount_expr(in, *xact->assigned_amount, xact.get(),
|
parse_amount_expr(in, *xact->assigned_amount, xact.get(),
|
||||||
static_cast<uint_least8_t>(expr_t::PARSE_NO_MIGRATE));
|
static_cast<uint_least8_t>(expr_t::PARSE_NO_MIGRATE));
|
||||||
|
|
||||||
|
#if defined(STORE_XACT_EXPRS)
|
||||||
if (xact->assigned_amount_expr) {
|
if (xact->assigned_amount_expr) {
|
||||||
end = in.tellg();
|
end = in.tellg();
|
||||||
xact->assigned_amount_expr->set_text
|
xact->assigned_amount_expr->set_text
|
||||||
(string("=") + string(line, long(beg), long(end - beg)));
|
(string("=") + string(line, long(beg), long(end - beg)));
|
||||||
}
|
}
|
||||||
|
#endif // STORE_XACT_EXPRS
|
||||||
}
|
}
|
||||||
|
|
||||||
if (xact->assigned_amount->is_null())
|
if (xact->assigned_amount->is_null())
|
||||||
|
|
|
||||||
|
|
@ -73,11 +73,17 @@ public:
|
||||||
account_t * account;
|
account_t * account;
|
||||||
|
|
||||||
amount_t amount; // can be null until finalization
|
amount_t amount; // can be null until finalization
|
||||||
|
#if defined(STORE_XACT_EXPRS)
|
||||||
optional<expr_t> amount_expr;
|
optional<expr_t> amount_expr;
|
||||||
|
#endif
|
||||||
optional<amount_t> cost;
|
optional<amount_t> cost;
|
||||||
|
#if defined(STORE_XACT_EXPRS)
|
||||||
optional<expr_t> cost_expr;
|
optional<expr_t> cost_expr;
|
||||||
|
#endif
|
||||||
optional<amount_t> assigned_amount;
|
optional<amount_t> assigned_amount;
|
||||||
|
#if defined(STORE_XACT_EXPRS)
|
||||||
optional<expr_t> assigned_amount_expr;
|
optional<expr_t> assigned_amount_expr;
|
||||||
|
#endif
|
||||||
|
|
||||||
xact_t(account_t * _account = NULL,
|
xact_t(account_t * _account = NULL,
|
||||||
flags_t _flags = ITEM_NORMAL)
|
flags_t _flags = ITEM_NORMAL)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue