Replaced keys, values and reverse with ranges

This commit is contained in:
anurag4u80
2021-03-31 23:33:04 +05:30
parent 851051c64a
commit bbcdddeed9
18 changed files with 56 additions and 53 deletions
+7 -6
View File
@@ -26,10 +26,11 @@
#include <libsolutil/Visitor.h>
#include <libsolutil/LEB128.h>
#include <boost/range/adaptor/reversed.hpp>
#include <boost/range/adaptor/map.hpp>
#include <boost/range/adaptor/transformed.hpp>
#include <range/v3/view/map.hpp>
#include <range/v3/view/reverse.hpp>
using namespace std;
using namespace solidity;
using namespace solidity::yul;
@@ -580,7 +581,7 @@ map<string, size_t> BinaryTransform::enumerateFunctionTypes(map<Type, vector<str
{
map<string, size_t> functionTypes;
size_t typeID = 0;
for (vector<string> const& funNames: _typeToFunctionMap | boost::adaptors::map_values)
for (vector<string> const& funNames: _typeToFunctionMap | ranges::views::values)
{
for (string const& name: funNames)
functionTypes[name] = typeID;
@@ -594,7 +595,7 @@ bytes BinaryTransform::typeSection(map<BinaryTransform::Type, vector<string>> co
{
bytes result;
size_t index = 0;
for (Type const& type: _typeToFunctionMap | boost::adaptors::map_keys)
for (Type const& type: _typeToFunctionMap | ranges::views::keys)
{
result += toBytes(ValueType::Function);
result += lebEncode(type.first.size()) + type.first;
@@ -695,7 +696,7 @@ bytes BinaryTransform::visit(vector<Expression> const& _expressions)
bytes BinaryTransform::visitReversed(vector<Expression> const& _expressions)
{
bytes result;
for (auto const& expr: _expressions | boost::adaptors::reversed)
for (auto const& expr: _expressions | ranges::views::reverse)
result += std::visit(*this, expr);
return result;
}
@@ -704,7 +705,7 @@ bytes BinaryTransform::encodeLabelIdx(string const& _label) const
{
yulAssert(!_label.empty(), "Empty label.");
size_t depth = 0;
for (string const& label: m_labels | boost::adaptors::reversed)
for (string const& label: m_labels | ranges::views::reverse)
if (label == _label)
return lebEncode(depth);
else