diff options
author | chriseth <chris@ethereum.org> | 2018-10-29 22:12:02 +0800 |
---|---|---|
committer | chriseth <chris@ethereum.org> | 2018-11-08 02:30:27 +0800 |
commit | 674e17c2a895eff6729357d8c10db709ac368b79 (patch) | |
tree | 300a55700b068709f36340563db1b43e5b8b1188 /libyul/optimiser/SimplificationRules.cpp | |
parent | 0a96f091ab63e8d77106e00590a442c59714eecb (diff) | |
download | dexon-solidity-674e17c2a895eff6729357d8c10db709ac368b79.tar.gz dexon-solidity-674e17c2a895eff6729357d8c10db709ac368b79.tar.zst dexon-solidity-674e17c2a895eff6729357d8c10db709ac368b79.zip |
Performance: Replace string by special single-copy YulString class.
Diffstat (limited to 'libyul/optimiser/SimplificationRules.cpp')
-rw-r--r-- | libyul/optimiser/SimplificationRules.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/libyul/optimiser/SimplificationRules.cpp b/libyul/optimiser/SimplificationRules.cpp index 8e94fe4d..5721042f 100644 --- a/libyul/optimiser/SimplificationRules.cpp +++ b/libyul/optimiser/SimplificationRules.cpp @@ -36,7 +36,7 @@ using namespace dev::yul; SimplificationRule<Pattern> const* SimplificationRules::findFirstMatch( Expression const& _expr, - map<string, Expression const*> const& _ssaValues + map<YulString, Expression const*> const& _ssaValues ) { if (_expr.type() != typeid(FunctionalInstruction)) @@ -104,7 +104,7 @@ void Pattern::setMatchGroup(unsigned _group, map<unsigned, Expression const*>& _ m_matchGroups = &_matchGroups; } -bool Pattern::matches(Expression const& _expr, map<string, Expression const*> const& _ssaValues) const +bool Pattern::matches(Expression const& _expr, map<YulString, Expression const*> const& _ssaValues) const { Expression const* expr = &_expr; @@ -112,7 +112,7 @@ bool Pattern::matches(Expression const& _expr, map<string, Expression const*> co // Do not do it for "Any" because we can check identity better for variables. if (m_kind != PatternKind::Any && _expr.type() == typeid(Identifier)) { - string const& varName = boost::get<Identifier>(_expr).name; + YulString varName = boost::get<Identifier>(_expr).name; if (_ssaValues.count(varName)) expr = _ssaValues.at(varName); } @@ -125,7 +125,7 @@ bool Pattern::matches(Expression const& _expr, map<string, Expression const*> co Literal const& literal = boost::get<Literal>(*expr); if (literal.kind != assembly::LiteralKind::Number) return false; - if (m_data && *m_data != u256(literal.value)) + if (m_data && *m_data != u256(literal.value.str())) return false; assertThrow(m_arguments.empty(), OptimizerException, ""); } @@ -193,7 +193,7 @@ Expression Pattern::toExpression(SourceLocation const& _location) const if (m_kind == PatternKind::Constant) { assertThrow(m_data, OptimizerException, "No match group and no constant value given."); - return Literal{_location, assembly::LiteralKind::Number, formatNumber(*m_data), ""}; + return Literal{_location, assembly::LiteralKind::Number, YulString{formatNumber(*m_data)}, {}}; } else if (m_kind == PatternKind::Operation) { @@ -209,8 +209,8 @@ u256 Pattern::d() const { Literal const& literal = boost::get<Literal>(matchGroupValue()); assertThrow(literal.kind == assembly::LiteralKind::Number, OptimizerException, ""); - assertThrow(isValidDecimal(literal.value) || isValidHex(literal.value), OptimizerException, ""); - return u256(literal.value); + assertThrow(isValidDecimal(literal.value.str()) || isValidHex(literal.value.str()), OptimizerException, ""); + return u256(literal.value.str()); } Expression const& Pattern::matchGroupValue() const |