Skip to content

Commit

Permalink
chore: Store vested per period in memory before iterating (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
fzavalia authored Nov 23, 2022
1 parent 619b42b commit a7a5c16
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions contracts/PeriodicTokenVesting.sol
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,11 @@ contract PeriodicTokenVesting is OwnableUpgradeable, PausableUpgradeable {
/// @return The total amount of tokens that will be vested in this contract.
function getTotal() public view returns (uint256) {
uint256 total;
uint256[] memory mVestedPerPeriod = vestedPerPeriod;

// Sum all the tokens vested per period to obtain the total amount.
for (uint i = 0; i < vestedPerPeriod.length; ) {
total += vestedPerPeriod[i];
for (uint256 i = 0; i < mVestedPerPeriod.length; ) {
total += mVestedPerPeriod[i];
unchecked {
++i;
}
Expand Down

0 comments on commit a7a5c16

Please sign in to comment.