Open
Description
Abstract and Motivation
type(uint256).max is often used as the indicator for something unlimited, such as approvals.
Solidity compiles type(uint256).max into PUSH32 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
This requires 33 bytes in the code (3 gas) for each situation type(uint256).max is used (such as comparison).
I propose much shorter approach for the case the optimiser is set to optimise bytecode length.
Compile to this instead (in the case the optimiser is set to optimise bytecode length):
PUSH0
NOT
This results in to 2 bytes code and 5 gas.
Backwards Compatibility
The optimised bytecode is shorter (-31 bytes), but has +2 gas. Functionally the same.