<x> += <y>
will cost more gas than <x> = <x> + <y>
for state variables. Similarly, <x> -= <y>
will cost more than <x> = <x> - <y>
.
Instances:
https://github.com/Cyfrin/2023-07-beedle/blob/main/src/Lender.sol#L263
pools[poolId].outstandingLoans += debt;
https://github.com/Cyfrin/2023-07-beedle/blob/main/src/Lender.sol#L388
pools[poolId].outstandingLoans += totalDebt;
https://github.com/Cyfrin/2023-07-beedle/blob/main/src/Lender.sol#L490
pools[poolId].outstandingLoans += totalDebt;
https://github.com/Cyfrin/2023-07-beedle/blob/main/src/Lender.sol#L637
pools[poolId].outstandingLoans += debt;
<x> = <x> + <y>
saves more gas than <x> += <y>
.
Manual review
Use <x> = <x> + <y>
wherever possible instead of using <x> += <y>
.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.