mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
[yul-phaser] Pass unique_ptr rather than a mutable reference to Program::applyOptimisationSteps()
- Giving the function ownership of an object and then receiving back another object is better than letting it implicitly modify data passed in an argument.
This commit is contained in:
parent
dd7a5c3386
commit
a189c8b6e2
@ -79,7 +79,7 @@ Program Program::load(CharStream& _sourceCode)
|
||||
|
||||
void Program::optimise(vector<string> const& _optimisationSteps)
|
||||
{
|
||||
applyOptimisationSteps(m_dialect, m_nameDispenser, *m_ast, _optimisationSteps);
|
||||
m_ast = applyOptimisationSteps(m_dialect, m_nameDispenser, move(m_ast), _optimisationSteps);
|
||||
}
|
||||
|
||||
ostream& phaser::operator<<(ostream& _stream, Program const& _program)
|
||||
@ -133,10 +133,10 @@ unique_ptr<Block> Program::disambiguateAST(
|
||||
return make_unique<Block>(get<Block>(disambiguator(_ast)));
|
||||
}
|
||||
|
||||
void Program::applyOptimisationSteps(
|
||||
unique_ptr<Block> Program::applyOptimisationSteps(
|
||||
Dialect const& _dialect,
|
||||
NameDispenser& _nameDispenser,
|
||||
Block& _ast,
|
||||
unique_ptr<Block> _ast,
|
||||
vector<string> const& _optimisationSteps
|
||||
)
|
||||
{
|
||||
@ -146,7 +146,9 @@ void Program::applyOptimisationSteps(
|
||||
OptimiserStepContext context{_dialect, _nameDispenser, externallyUsedIdentifiers};
|
||||
|
||||
for (string const& step: _optimisationSteps)
|
||||
OptimiserSuite::allSteps().at(step)->run(context, _ast);
|
||||
OptimiserSuite::allSteps().at(step)->run(context, *_ast);
|
||||
|
||||
return _ast;
|
||||
}
|
||||
|
||||
size_t Program::computeCodeSize(Block const& _ast)
|
||||
|
@ -97,10 +97,10 @@ private:
|
||||
yul::Block const& _ast,
|
||||
yul::AsmAnalysisInfo const& _analysisInfo
|
||||
);
|
||||
static void applyOptimisationSteps(
|
||||
static std::unique_ptr<yul::Block> applyOptimisationSteps(
|
||||
yul::Dialect const& _dialect,
|
||||
yul::NameDispenser& _nameDispenser,
|
||||
yul::Block& _ast,
|
||||
std::unique_ptr<yul::Block> _ast,
|
||||
std::vector<std::string> const& _optimisationSteps
|
||||
);
|
||||
static size_t computeCodeSize(yul::Block const& _ast);
|
||||
|
Loading…
Reference in New Issue
Block a user