Minor refactoring removing unnecessary temporary variable.

This commit is contained in:
Patrick Lühne 2016-06-08 01:31:14 +02:00
parent 069ad4ca99
commit 42559fd601
2 changed files with 5 additions and 14 deletions

View File

@ -31,7 +31,7 @@ class Action
const Expression &effect() const;
private:
Action(std::string name);
Action() = default;
std::string m_name;

View File

@ -21,18 +21,11 @@ namespace pddl
//
////////////////////////////////////////////////////////////////////////////////////////////////////
Action::Action(std::string name)
: m_name{name}
{
}
////////////////////////////////////////////////////////////////////////////////////////////////////
void Action::parseDeclaration(Context &context, Domain &domain)
{
const auto actionName = context.parser.parseIdentifier(isIdentifier);
auto action = std::make_unique<Action>(Action());
auto action = std::make_unique<Action>(Action(actionName));
action->m_name = context.parser.parseIdentifier(isIdentifier);
context.parser.expect<std::string>(":parameters");
context.parser.expect<std::string>("(");
@ -49,11 +42,9 @@ void Action::parseDeclaration(Context &context, Domain &domain)
{
context.parser.expect<std::string>(":");
const auto sectionIdentifier = context.parser.parseIdentifier(isIdentifier);
if (sectionIdentifier == "precondition")
if (context.parser.probe<std::string>("precondition"))
action->m_precondition = parsePreconditionExpression(context, expressionContext);
else if (sectionIdentifier == "effect")
else if (context.parser.probe<std::string>("effect"))
action->m_effect = parseEffectExpression(context, expressionContext);
context.parser.skipWhiteSpace();