Skip to content

Commit

Permalink
Do not cache checkpoint to memory in GovernorVotesQuorumFraction
Browse files Browse the repository at this point in the history
  • Loading branch information
0xVolosnikov committed Aug 5, 2023
1 parent 54a235f commit 3a57b7d
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,11 @@ abstract contract GovernorVotesQuorumFraction is GovernorVotes {
uint256 length = _quorumNumeratorHistory._checkpoints.length;

// Optimistic search, check the latest checkpoint
Checkpoints.Checkpoint224 memory latest = _quorumNumeratorHistory._checkpoints[length - 1];
if (latest._key <= timepoint) {
return latest._value;
Checkpoints.Checkpoint224 storage latest = _quorumNumeratorHistory._checkpoints[length - 1];
uint32 latestKey = latest._key;
uint224 latestValue = latest._value;
if (latestKey <= timepoint) {
return latestValue;
}

// Otherwise, do the binary search
Expand Down

0 comments on commit 3a57b7d

Please sign in to comment.