Make use of make_vector where possible.

This commit is contained in:
Daniel Kirchner
2019-05-17 10:08:53 +02:00
parent 2046e61c26
commit 05c210772a
3 changed files with 40 additions and 54 deletions
+13 -23
View File
@@ -72,11 +72,7 @@ OptionalStatements reduceNoCaseSwitch(Switch& _switchStmt)
auto loc = locationOf(*_switchStmt.expression);
OptionalStatements s = vector<Statement>{};
s->emplace_back(makePopExpressionStatement(loc, std::move(*_switchStmt.expression)));
return s;
return make_vector<Statement>(makePopExpressionStatement(loc, std::move(*_switchStmt.expression)));
}
OptionalStatements reduceSingleCaseSwitch(Switch& _switchStmt)
@@ -86,26 +82,20 @@ OptionalStatements reduceSingleCaseSwitch(Switch& _switchStmt)
auto& switchCase = _switchStmt.cases.front();
auto loc = locationOf(*_switchStmt.expression);
if (switchCase.value)
{
OptionalStatements s = vector<Statement>{};
s->emplace_back(If{
std::move(_switchStmt.location),
make_unique<Expression>(FunctionalInstruction{
std::move(loc),
dev::eth::Instruction::EQ,
{std::move(*switchCase.value), std::move(*_switchStmt.expression)}
}),
std::move(switchCase.body)
return make_vector<Statement>(If{
std::move(_switchStmt.location),
make_unique<Expression>(FunctionalInstruction{
std::move(loc),
dev::eth::Instruction::EQ,
{std::move(*switchCase.value), std::move(*_switchStmt.expression)}
}),
std::move(switchCase.body)
});
return s;
}
else
{
OptionalStatements s = vector<Statement>{};
s->emplace_back(makePopExpressionStatement(loc, std::move(*_switchStmt.expression)));
s->emplace_back(std::move(switchCase.body));
return s;
}
return make_vector<Statement>(
makePopExpressionStatement(loc, std::move(*_switchStmt.expression)),
std::move(switchCase.body)
);
}
}