mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Adjust cost of literal zero.
This commit is contained in:
@@ -70,8 +70,14 @@ size_t CodeWeights::costOf(Expression const& _expression) const
|
||||
return functionCallCost;
|
||||
else if (holds_alternative<Identifier>(_expression))
|
||||
return identifierCost;
|
||||
else if (holds_alternative<Literal>(_expression))
|
||||
return literalCost;
|
||||
else if (Literal const* literal = get_if<Literal>(&_expression))
|
||||
{
|
||||
// Avoid strings because they could be longer than 32 bytes.
|
||||
if (literal->kind != LiteralKind::String && valueOfLiteral(*literal) == 0)
|
||||
return literalZeroCost;
|
||||
else
|
||||
return literalCost;
|
||||
}
|
||||
else
|
||||
yulAssert(false, "If you add a new expression type, you must update CodeWeights.");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user