You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I found this library from a third contract. And maybe some codes can be optimized to save gas. For example: xc > 0x1 is better than xc >= 0x2. In Solidity, there is no single op-code for ≤ or ≥ expressions. Solidity compiler executes the LT/GT (less than/greater than) op-code and afterwards it executes an ISZERO op-code to check if the result of the previous comparison (LT/ GT) is zero and validate it or not. So the use of < and > are cheaper than ≤ and ≥.
The text was updated successfully, but these errors were encountered:
I found this library from a third contract. And maybe some codes can be optimized to save gas. For example:
xc > 0x1
is better thanxc >= 0x2
. In Solidity, there is no single op-code for ≤ or ≥ expressions. Solidity compiler executes the LT/GT (less than/greater than) op-code and afterwards it executes an ISZERO op-code to check if the result of the previous comparison (LT/ GT) is zero and validate it or not. So the use of < and > are cheaper than ≤ and ≥.The text was updated successfully, but these errors were encountered: