cryptokitties-bounty-2
cryptokitties-bounty-2 copied to clipboard
major gas inefficiency in batchRemoveExpired due to state variable re-write at every iteration
Description
In batchRemoveExpired
, at every iteration totalCFOEarnings
is updated. Each update corresponds to updating a state variable which costs 5000 gas each time.
Fix
In the beginning of batchRemoveExpired
create a local variable called tempEarnings
initialized to 0. Use this local variable instead to keep track of the CFO earnings. In the end, set totatotalCFOEarnings = tempEarnings
once.
Thanks @sunsetlover for your feedback! We will take it into consideration
Thanks for your participation, @sunsetlover! Our team has reviewed your submission, and we are pleased to reward you for your report.
Severity: Med Points: 250