aboutsummaryrefslogtreecommitdiffstats
path: root/libyul/optimiser/DataFlowAnalyzer.cpp
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-10-29 22:12:02 +0800
committerchriseth <chris@ethereum.org>2018-11-08 02:30:27 +0800
commit674e17c2a895eff6729357d8c10db709ac368b79 (patch)
tree300a55700b068709f36340563db1b43e5b8b1188 /libyul/optimiser/DataFlowAnalyzer.cpp
parent0a96f091ab63e8d77106e00590a442c59714eecb (diff)
downloaddexon-solidity-674e17c2a895eff6729357d8c10db709ac368b79.tar
dexon-solidity-674e17c2a895eff6729357d8c10db709ac368b79.tar.gz
dexon-solidity-674e17c2a895eff6729357d8c10db709ac368b79.tar.bz2
dexon-solidity-674e17c2a895eff6729357d8c10db709ac368b79.tar.lz
dexon-solidity-674e17c2a895eff6729357d8c10db709ac368b79.tar.xz
dexon-solidity-674e17c2a895eff6729357d8c10db709ac368b79.tar.zst
dexon-solidity-674e17c2a895eff6729357d8c10db709ac368b79.zip
Performance: Replace string by special single-copy YulString class.
Diffstat (limited to 'libyul/optimiser/DataFlowAnalyzer.cpp')
-rw-r--r--libyul/optimiser/DataFlowAnalyzer.cpp26
1 files changed, 13 insertions, 13 deletions
diff --git a/libyul/optimiser/DataFlowAnalyzer.cpp b/libyul/optimiser/DataFlowAnalyzer.cpp
index 7ac42c30..1ff1d2f0 100644
--- a/libyul/optimiser/DataFlowAnalyzer.cpp
+++ b/libyul/optimiser/DataFlowAnalyzer.cpp
@@ -38,9 +38,9 @@ using namespace dev::yul;
void DataFlowAnalyzer::operator()(Assignment& _assignment)
{
- set<string> names;
+ set<YulString> names;
for (auto const& var: _assignment.variableNames)
- names.insert(var.name);
+ names.emplace(var.name);
assertThrow(_assignment.value, OptimizerException, "");
visit(*_assignment.value);
handleAssignment(names, _assignment.value.get());
@@ -48,9 +48,9 @@ void DataFlowAnalyzer::operator()(Assignment& _assignment)
void DataFlowAnalyzer::operator()(VariableDeclaration& _varDecl)
{
- set<string> names;
+ set<YulString> names;
for (auto const& var: _varDecl.variables)
- names.insert(var.name);
+ names.emplace(var.name);
m_variableScopes.back().variables += names;
if (_varDecl.value)
visit(*_varDecl.value);
@@ -69,7 +69,7 @@ void DataFlowAnalyzer::operator()(If& _if)
void DataFlowAnalyzer::operator()(Switch& _switch)
{
visit(*_switch.expression);
- set<string> assignedVariables;
+ set<YulString> assignedVariables;
for (auto& _case: _switch.cases)
{
(*this)(_case.body);
@@ -86,9 +86,9 @@ void DataFlowAnalyzer::operator()(FunctionDefinition& _fun)
{
pushScope(true);
for (auto const& parameter: _fun.parameters)
- m_variableScopes.back().variables.insert(parameter.name);
+ m_variableScopes.back().variables.emplace(parameter.name);
for (auto const& var: _fun.returnVariables)
- m_variableScopes.back().variables.insert(var.name);
+ m_variableScopes.back().variables.emplace(var.name);
ASTModifier::operator()(_fun);
popScope();
}
@@ -122,7 +122,7 @@ void DataFlowAnalyzer::operator()(Block& _block)
assertThrow(numScopes == m_variableScopes.size(), OptimizerException, "");
}
-void DataFlowAnalyzer::handleAssignment(set<string> const& _variables, Expression* _value)
+void DataFlowAnalyzer::handleAssignment(set<YulString> const& _variables, Expression* _value)
{
clearValues(_variables);
@@ -131,7 +131,7 @@ void DataFlowAnalyzer::handleAssignment(set<string> const& _variables, Expressio
movableChecker.visit(*_value);
if (_variables.size() == 1)
{
- string const& name = *_variables.begin();
+ YulString name = *_variables.begin();
// Expression has to be movable and cannot contain a reference
// to the variable that will be assigned to.
if (_value && movableChecker.movable() && !movableChecker.referencedVariables().count(name))
@@ -143,7 +143,7 @@ void DataFlowAnalyzer::handleAssignment(set<string> const& _variables, Expressio
{
m_references[name] = referencedVariables;
for (auto const& ref: referencedVariables)
- m_referencedBy[ref].insert(name);
+ m_referencedBy[ref].emplace(name);
}
}
@@ -158,7 +158,7 @@ void DataFlowAnalyzer::popScope()
m_variableScopes.pop_back();
}
-void DataFlowAnalyzer::clearValues(set<string> _variables)
+void DataFlowAnalyzer::clearValues(set<YulString> _variables)
{
// All variables that reference variables to be cleared also have to be
// cleared, but not recursively, since only the value of the original
@@ -176,7 +176,7 @@ void DataFlowAnalyzer::clearValues(set<string> _variables)
// Clear variables that reference variables to be cleared.
for (auto const& name: _variables)
for (auto const& ref: m_referencedBy[name])
- _variables.insert(ref);
+ _variables.emplace(ref);
// Clear the value and update the reference relation.
for (auto const& name: _variables)
@@ -189,7 +189,7 @@ void DataFlowAnalyzer::clearValues(set<string> _variables)
}
}
-bool DataFlowAnalyzer::inScope(string const& _variableName) const
+bool DataFlowAnalyzer::inScope(YulString _variableName) const
{
for (auto const& scope: m_variableScopes | boost::adaptors::reversed)
{