aboutsummaryrefslogtreecommitdiffstats
path: root/libyul/optimiser/StructuralSimplifier.cpp
diff options
context:
space:
mode:
authorChristian Parpart <christian@ethereum.org>2019-01-09 21:05:03 +0800
committerChristian Parpart <christian@ethereum.org>2019-01-16 21:58:59 +0800
commit065c3c87af0cd4f620d929a01b2902edf6c5892d (patch)
treecb33b216ddec2415c6cde661fe9cc90326123c48 /libyul/optimiser/StructuralSimplifier.cpp
parent778b14de260a7eeaea88867e39cfc226f1494e63 (diff)
downloaddexon-solidity-065c3c87af0cd4f620d929a01b2902edf6c5892d.tar.gz
dexon-solidity-065c3c87af0cd4f620d929a01b2902edf6c5892d.tar.zst
dexon-solidity-065c3c87af0cd4f620d929a01b2902edf6c5892d.zip
libyul: changing some AST members from shared_ptr<> to unique_ptr<>
* Some spaces look a little more verbose now, but that shouln't be a problem as it also should raise readability, too. * This makes some use of return-value-optimizations also.
Diffstat (limited to 'libyul/optimiser/StructuralSimplifier.cpp')
-rw-r--r--libyul/optimiser/StructuralSimplifier.cpp26
1 files changed, 18 insertions, 8 deletions
diff --git a/libyul/optimiser/StructuralSimplifier.cpp b/libyul/optimiser/StructuralSimplifier.cpp
index 8d7dcd57..727775cb 100644
--- a/libyul/optimiser/StructuralSimplifier.cpp
+++ b/libyul/optimiser/StructuralSimplifier.cpp
@@ -51,7 +51,11 @@ void StructuralSimplifier::simplify(std::vector<yul::Statement>& _statements)
GenericFallbackReturnsVisitor<OptionalStatements, If, Switch, ForLoop> const visitor(
[&](If& _ifStmt) -> OptionalStatements {
if (_ifStmt.body.statements.empty())
- return {{makePopExpressionStatement(_ifStmt.location, std::move(*_ifStmt.condition))}};
+ {
+ OptionalStatements s = vector<Statement>{};
+ s->emplace_back(makePopExpressionStatement(_ifStmt.location, std::move(*_ifStmt.condition)));
+ return s;
+ }
if (expressionAlwaysTrue(*_ifStmt.condition))
return {std::move(_ifStmt.body.statements)};
else if (expressionAlwaysFalse(*_ifStmt.condition))
@@ -64,18 +68,24 @@ void StructuralSimplifier::simplify(std::vector<yul::Statement>& _statements)
auto& switchCase = _switchStmt.cases.front();
auto loc = locationOf(*_switchStmt.expression);
if (switchCase.value)
- return {{If{
+ {
+ OptionalStatements s = vector<Statement>{};
+ s->emplace_back(If{
std::move(_switchStmt.location),
- make_shared<Expression>(FunctionalInstruction{
+ make_unique<Expression>(FunctionalInstruction{
std::move(loc),
solidity::Instruction::EQ,
{std::move(*switchCase.value), std::move(*_switchStmt.expression)}
- }), std::move(switchCase.body)}}};
+ }), std::move(switchCase.body)});
+ return s;
+ }
else
- return {{
- makePopExpressionStatement(loc, std::move(*_switchStmt.expression)),
- std::move(switchCase.body)
- }};
+ {
+ OptionalStatements s = vector<Statement>{};
+ s->emplace_back(makePopExpressionStatement(loc, std::move(*_switchStmt.expression)));
+ s->emplace_back(std::move(switchCase.body));
+ return s;
+ }
}
else
return {};