mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Move filter to CommonData.h
This commit is contained in:
parent
7ea96c5583
commit
06d719e4f1
@ -163,6 +163,22 @@ auto applyMap(Container const& _c, Callable&& _op, OutputContainer _oc = OutputC
|
||||
return _oc;
|
||||
}
|
||||
|
||||
/// Filter a vector.
|
||||
/// Returns a copy of the vector after only taking indices `i` such that `_mask[i]` is true.
|
||||
template<typename T>
|
||||
std::vector<T> filter(std::vector<T> const& _vec, std::vector<bool> const& _mask)
|
||||
{
|
||||
assert(_vec.size() == _mask.size());
|
||||
|
||||
std::vector<T> ret;
|
||||
|
||||
for (size_t i = 0; i < _mask.size(); ++i)
|
||||
if (_mask[i])
|
||||
ret.push_back(_vec[i]);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// Functional fold.
|
||||
/// Given a container @param _c, an initial value @param _acc,
|
||||
/// and a binary operator @param _binaryOp(T, U), accumulate
|
||||
|
@ -25,20 +25,6 @@
|
||||
namespace solidity::yul::unusedFunctionsCommon
|
||||
{
|
||||
|
||||
template<typename T>
|
||||
std::vector<T> filter(std::vector<T> const& _vec, std::vector<bool> const& _mask)
|
||||
{
|
||||
yulAssert(_vec.size() == _mask.size(), "");
|
||||
|
||||
std::vector<T> ret;
|
||||
|
||||
for (size_t i = 0; i < _mask.size(); ++i)
|
||||
if (_mask[i])
|
||||
ret.push_back(_vec[i]);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// Returns true if applying UnusedFunctionParameterPruner is not helpful or redundant because the
|
||||
/// inliner will be able to handle it anyway.
|
||||
inline bool tooSimpleToBePruned(FunctionDefinition const& _f)
|
||||
|
Loading…
Reference in New Issue
Block a user