Adjust cost of literal zero.

This commit is contained in:
chriseth
2021-04-22 11:42:42 +02:00
parent 1eff128b6d
commit 35b651103d
30 changed files with 172 additions and 212 deletions
+8 -2
View File
@@ -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.");
}