A list of common Solidity optimization tips and myths.
The SHR
opcode is 3 gas cheaper than DIV
and also bypasses Solidity's division by 0 prevention overhead.
// Unoptimized:
uint256 two = 4 / 2;
// Optimized:
uint256 two = 4 >> 1;
A list of common Solidity optimization tips and myths.
The SHR
opcode is 3 gas cheaper than DIV
and also bypasses Solidity's division by 0 prevention overhead.
// Unoptimized:
uint256 two = 4 / 2;
// Optimized:
uint256 two = 4 >> 1;