yearn / veYFI

Voting YFI

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Load array length in memory before looping

0xbok opened this issue · comments

commented

https://github.com/yearn/veYfi/blob/4fab1224cd159735d2eb70a669efdd7527066218/contracts/Gauge.sol#L132

In cases like these, we can do:

uint256 len = extraRewards.length;
for (uint256 i = 0; i < len; i++) {

After updating all cases like these, brownie test --gas showed gas savings.

commented

removeExtraReward isn't going to be called often, can you find other places where these changes can save gas?

commented

Can you create a PR, pay attention and please remove the linting changes.