mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Add and use cxx20::ranges::all_of.
This commit is contained in:
parent
970e8064bb
commit
3ed55613ba
@ -49,4 +49,16 @@ erase_if(std::unordered_map<Key,T,Hash,KeyEqual,Alloc>& c, Pred pred)
|
|||||||
return old_size - c.size();
|
return old_size - c.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace ranges
|
||||||
|
{
|
||||||
|
template<typename R, typename Pred>
|
||||||
|
inline constexpr bool all_of(R&& r, Pred pred)
|
||||||
|
{
|
||||||
|
for (auto it = std::begin(r), end = std::end(r); it != end; ++it)
|
||||||
|
if (!std::invoke(pred, *it))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,8 @@
|
|||||||
#include <libyul/Exceptions.h>
|
#include <libyul/Exceptions.h>
|
||||||
#include <libyul/AST.h>
|
#include <libyul/AST.h>
|
||||||
|
|
||||||
|
#include <libsolutil/cxx20.h>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace solidity;
|
using namespace solidity;
|
||||||
using namespace solidity::yul;
|
using namespace solidity::yul;
|
||||||
@ -86,10 +88,7 @@ void Rematerialiser::visit(Expression& _e)
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
assertThrow(m_referenceCounts[name] > 0, OptimizerException, "");
|
assertThrow(m_referenceCounts[name] > 0, OptimizerException, "");
|
||||||
bool allInScope = true;
|
if (cxx20::ranges::all_of(m_references[name], [&](auto const& ref) { return inScope(ref); }))
|
||||||
for (auto const& ref: m_references[name])
|
|
||||||
allInScope = allInScope && inScope(ref);
|
|
||||||
if (allInScope)
|
|
||||||
{
|
{
|
||||||
// update reference counts
|
// update reference counts
|
||||||
m_referenceCounts[name]--;
|
m_referenceCounts[name]--;
|
||||||
|
Loading…
Reference in New Issue
Block a user