Open codehawks-bot opened 1 year ago
Gas Optimization / Informational
https://github.com/Cyfrin/2023-07-foundry-defi-stablecoin/blob/d1c5501aa79320ca0aeaa73f47f0dbc88c7b77e2/src/DecentralizedStableCoin.sol#L61
Can save gas we change less or equal to just equal.
A <= 0 check is done on a uint, which can not be negative. We can save gas if we just do an equality check
<= 0
== 0 costs less gas than <= 0
== 0
Manual review
Change this:
if (_amount <= 0) { revert DecentralizedStableCoin__MustBeMoreThanZero(); }
To this:
if (_amount == 0) { revert DecentralizedStableCoin__MustBeMoreThanZero(); }
Can save gas we by changing less or equal to just equal
Severity
Gas Optimization / Informational
Relevant GitHub Links
https://github.com/Cyfrin/2023-07-foundry-defi-stablecoin/blob/d1c5501aa79320ca0aeaa73f47f0dbc88c7b77e2/src/DecentralizedStableCoin.sol#L61
Summary
Can save gas we change less or equal to just equal.
Vulnerability Details
A
<= 0
check is done on a uint, which can not be negative. We can save gas if we just do an equality checkImpact
== 0
costs less gas than<= 0
Tools Used
Manual review
Recommendations
Change this:
To this: