File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -91,9 +91,17 @@ u256 solidity::yul::valueOfNumberLiteral(Literal const& _literal)
91
91
{
92
92
yulAssert (_literal.kind == LiteralKind::Number, " Expected number literal!" );
93
93
94
- std::string const & literalString = _literal.value .str ();
95
- yulAssert (isValidDecimal (literalString) || isValidHex (literalString), " Invalid number literal!" );
96
- return u256 (literalString);
94
+ static map<YulString, u256> numberCache;
95
+ static YulStringRepository::ResetCallback callback{[&] { numberCache.clear (); }};
96
+
97
+ auto && [it, isNew] = numberCache.try_emplace (_literal.value , 0 );
98
+ if (isNew)
99
+ {
100
+ std::string const & literalString = _literal.value .str ();
101
+ yulAssert (isValidDecimal (literalString) || isValidHex (literalString), " Invalid number literal!" );
102
+ it->second = u256 (literalString);
103
+ }
104
+ return it->second ;
97
105
}
98
106
99
107
u256 solidity::yul::valueOfStringLiteral (Literal const & _literal)
You can’t perform that action at this time.
0 commit comments