Open
Description
Handle
pants
Vulnerability details
You can cache the array length to save length access gas cost at every iteration.
The following (bad) form appears at GovernorAlpha.sol line 571 and LinearVesting.sol line 72.
GovernorAlpha.sol example:
for (uint256 i = 0; i < _targets.length; i++) {
if (_targets[i] == address(this)) {
revert(
"GovernorAlpha::veto: council cannot veto on proposal having action with address(this) as target"
);
}
}
Change it to:
uint256 len = _targets.length;
for (uint256 i = 0; i < len; i++) {
if (_targets[i] == address(this)) {
revert(
"GovernorAlpha::veto: council cannot veto on proposal having action with address(this) as target"
);
}
}