Open codehawks-bot opened 1 year ago
Gas Optimization / Informational
https://github.com/Cyfrin/2023-07-escrow/blob/main/src/Escrow.sol#L119
https://github.com/Cyfrin/2023-07-escrow/blob/main/src/Escrow.sol#L122
https://github.com/Cyfrin/2023-07-escrow/blob/main/src/Escrow.sol#L126
The compiler uses opcodes GT and ISZERO for solidity code that uses >, but only requires LT for >=, which saves 3 gas Reference: https://gist.github.com/IllIllI000/3dc79d25acccfa16dee4e83ffdc6ffde
file: /src/Escrow.sol 119 if (buyerAward > 0) {
file: /src/Escrow.sol 122 if (i_arbiterFee > 0) {
file: /src/Escrow.sol 126 if (tokenBalance > 0) {
>= costs less gas than >
Severity
Gas Optimization / Informational
Relevant GitHub Links
https://github.com/Cyfrin/2023-07-escrow/blob/main/src/Escrow.sol#L119
https://github.com/Cyfrin/2023-07-escrow/blob/main/src/Escrow.sol#L122
https://github.com/Cyfrin/2023-07-escrow/blob/main/src/Escrow.sol#L126
Summary
[G-9] >= costs less gas than >
The compiler uses opcodes GT and ISZERO for solidity code that uses >, but only requires LT for >=, which saves 3 gas Reference: https://gist.github.com/IllIllI000/3dc79d25acccfa16dee4e83ffdc6ffde
https://github.com/Cyfrin/2023-07-escrow/blob/main/src/Escrow.sol#L119
https://github.com/Cyfrin/2023-07-escrow/blob/main/src/Escrow.sol#L122
https://github.com/Cyfrin/2023-07-escrow/blob/main/src/Escrow.sol#L126