Skip to content

Commit

Permalink
Use iterateReplacing in StatementRemover.
Browse files Browse the repository at this point in the history
  • Loading branch information
chriseth committed Sep 16, 2021
1 parent 9d29b1e commit 280ff8c
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions libyul/optimiser/RedundantStoreBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,15 @@ void RedundantStoreBase::merge(TrackedStores& _target, vector<TrackedStores>&& _

void StatementRemover::operator()(Block& _block)
{
ranges::actions::remove_if(_block.statements, [&](Statement const& _statement) -> bool {
return m_toRemove.count(&_statement);
});
util::iterateReplacing(
_block.statements,
[&](Statement& _statement) -> std::optional<vector<Statement>>
{
if (m_toRemove.count(&_statement))
return {vector<Statement>{}};
else
return nullopt;
}
);
ASTModifier::operator()(_block);
}

0 comments on commit 280ff8c

Please sign in to comment.