diff options
author | chriseth <c@ethdev.com> | 2015-05-06 19:56:40 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2015-05-06 19:56:40 +0800 |
commit | c731ae92ca68c2e2cdf761bdf1f81e27097e50fc (patch) | |
tree | a9b3ab8594588f65e325dd011d98602b253772ba | |
parent | c3e5fe6a1205068c9b5ded84f8ae96d97f855c1b (diff) | |
download | dexon-solidity-c731ae92ca68c2e2cdf761bdf1f81e27097e50fc.tar dexon-solidity-c731ae92ca68c2e2cdf761bdf1f81e27097e50fc.tar.gz dexon-solidity-c731ae92ca68c2e2cdf761bdf1f81e27097e50fc.tar.bz2 dexon-solidity-c731ae92ca68c2e2cdf761bdf1f81e27097e50fc.tar.lz dexon-solidity-c731ae92ca68c2e2cdf761bdf1f81e27097e50fc.tar.xz dexon-solidity-c731ae92ca68c2e2cdf761bdf1f81e27097e50fc.tar.zst dexon-solidity-c731ae92ca68c2e2cdf761bdf1f81e27097e50fc.zip |
Use std::array.
-rw-r--r-- | StructuralGasEstimator.cpp | 6 | ||||
-rw-r--r-- | StructuralGasEstimator.h | 7 |
2 files changed, 8 insertions, 5 deletions
diff --git a/StructuralGasEstimator.cpp b/StructuralGasEstimator.cpp index 2cf8c2a8..c90981a7 100644 --- a/StructuralGasEstimator.cpp +++ b/StructuralGasEstimator.cpp @@ -31,7 +31,7 @@ using namespace dev; using namespace dev::eth; using namespace dev::solidity; -map<ASTNode const*, GasMeter::GasConsumption[2]> StructuralGasEstimator::performEstimation( +StructuralGasEstimator::ASTGasConsumptionSelfAccumulated StructuralGasEstimator::performEstimation( AssemblyItems const& _items, vector<ASTNode const*> const& _ast ) @@ -42,7 +42,7 @@ map<ASTNode const*, GasMeter::GasConsumption[2]> StructuralGasEstimator::perform for (auto const& item: _items) particularCosts[item.getLocation()] += meter.estimateMax(item); - map<ASTNode const*, GasMeter::GasConsumption[2]> gasCosts; + ASTGasConsumptionSelfAccumulated gasCosts; auto onNode = [&](ASTNode const& _node) { gasCosts[&_node][0] = gasCosts[&_node][1] = particularCosts[_node.getLocation()]; @@ -60,7 +60,7 @@ map<ASTNode const*, GasMeter::GasConsumption[2]> StructuralGasEstimator::perform } map<ASTNode const*, GasMeter::GasConsumption> StructuralGasEstimator::breakToStatementLevel( - map<ASTNode const*, GasMeter::GasConsumption[2]> const& _gasCosts, + ASTGasConsumptionSelfAccumulated const& _gasCosts, vector<ASTNode const*> const& _roots ) { diff --git a/StructuralGasEstimator.h b/StructuralGasEstimator.h index b9e97643..df1ae509 100644 --- a/StructuralGasEstimator.h +++ b/StructuralGasEstimator.h @@ -24,6 +24,7 @@ #include <vector> #include <map> +#include <array> #include <libsolidity/ASTForward.h> #include <libevmasm/GasMeter.h> #include <libevmasm/Assembly.h> @@ -37,11 +38,13 @@ class StructuralGasEstimator { public: using ASTGasConsumption = std::map<ASTNode const*, eth::GasMeter::GasConsumption>; + using ASTGasConsumptionSelfAccumulated = + std::map<ASTNode const*, std::array<eth::GasMeter::GasConsumption, 2>>; /// Estimates the gas consumption for every assembly item in the given assembly and stores /// it by source location. /// @returns a mapping from each AST node to a pair of its particular and syntactically accumulated gas costs. - std::map<ASTNode const*, eth::GasMeter::GasConsumption[2]> performEstimation( + ASTGasConsumptionSelfAccumulated performEstimation( eth::AssemblyItems const& _items, std::vector<ASTNode const*> const& _ast ); @@ -50,7 +53,7 @@ public: /// 1. source locations of statements that do not contain other statements /// 2. maximal source locations that do not overlap locations coming from the first rule ASTGasConsumption breakToStatementLevel( - std::map<ASTNode const*, eth::GasMeter::GasConsumption[2]> const& _gasCosts, + ASTGasConsumptionSelfAccumulated const& _gasCosts, std::vector<ASTNode const*> const& _roots ); }; |