Optimizations

This commit is contained in:
John Wiegley 2012-02-27 11:52:27 -06:00
parent 5532a1a8b7
commit 3ed09fc85b
2 changed files with 62 additions and 55 deletions

View file

@ -136,6 +136,7 @@ account_t * journal_t::register_account(const string& name, post_t * post,
}
}
if (checking_style == CHECK_WARNING || checking_style == CHECK_ERROR) {
if (! result->has_flags(ACCOUNT_KNOWN)) {
if (! post) {
if (force_checking)
@ -153,6 +154,7 @@ account_t * journal_t::register_account(const string& name, post_t * post,
throw_(parse_error, _("Unknown account '%1'") << result->fullname());
}
}
}
return result;
}
@ -197,6 +199,7 @@ void journal_t::register_commodity(commodity_t& comm,
variant<int, xact_t *, post_t *> context,
const string& location)
{
if (checking_style == CHECK_WARNING || checking_style == CHECK_ERROR) {
if (! comm.has_flags(COMMODITY_KNOWN)) {
if (context.which() == 0) {
if (force_checking)
@ -218,6 +221,7 @@ void journal_t::register_commodity(commodity_t& comm,
}
}
}
}
namespace {
void check_metadata(journal_t& journal,
@ -254,6 +258,7 @@ void journal_t::register_metadata(const string& key, const value_t& value,
variant<int, xact_t *, post_t *> context,
const string& location)
{
if (checking_style == CHECK_WARNING || checking_style == CHECK_ERROR) {
std::set<string>::iterator i = known_tags.find(key);
if (i == known_tags.end()) {
@ -276,6 +281,7 @@ void journal_t::register_metadata(const string& key, const value_t& value,
throw_(parse_error, _("Unknown metadata tag '%1'") << key);
}
}
}
if (! value.is_null())
check_metadata(*this, key, value, context, location);

View file

@ -565,7 +565,6 @@ bool xact_t::valid() const
}
namespace {
bool post_pred(expr_t::ptr_op_t op, post_t& post)
{
switch (op->kind) {
@ -582,6 +581,9 @@ namespace {
else
break;
case expr_t::op_t::O_EQ:
return post_pred(op->left(), post) == post_pred(op->right(), post);
case expr_t::op_t::O_NOT:
return ! post_pred(op->left(), post);
@ -604,8 +606,7 @@ namespace {
throw_(calc_error, _("Unhandled operator"));
return false;
}
} // unnamed namespace
}
void auto_xact_t::extend_xact(xact_base_t& xact)
{