20,000 USDC
View results
Submission Details
Severity: gas
Valid

## [G-29] Use != 0 instead of > 0 for unsigned integer comparison

Summary

[G-29] Use != 0 instead of > 0 for unsigned integer comparison

it's generally more gas-efficient to use != 0 instead of > 0 when
comparing unsigned integer types.
This is because the Solidity compiler can optimize the != 0 comparison to a simple bitwise operation,
while the > 0 comparison requires an additional subtraction operation.
As a result, using != 0 can be more gas-efficient and can help to reduce the overall cost of your contract.

file: /src/Staking.sol
63 if (totalSupply > 0) {

https://github.com/Cyfrin/2023-07-beedle/blob/main/src/Staking.sol#L63

file: /src/Staking.sol
83 if (_supplied > 0) {

https://github.com/Cyfrin/2023-07-beedle/blob/main/src/Staking.sol#L83

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.