Refactor access to Checkpoint struct without using memory (#4512)

This commit is contained in:
Vladislav Volosnikov
2023-08-26 01:17:32 +02:00
committed by GitHub
parent b2e7bab920
commit a5ed318634

View File

@ -49,9 +49,11 @@ abstract contract GovernorVotesQuorumFraction is GovernorVotes {
uint256 length = _quorumNumeratorHistory._checkpoints.length; uint256 length = _quorumNumeratorHistory._checkpoints.length;
// Optimistic search, check the latest checkpoint // Optimistic search, check the latest checkpoint
Checkpoints.Checkpoint224 memory latest = _quorumNumeratorHistory._checkpoints[length - 1]; Checkpoints.Checkpoint224 storage latest = _quorumNumeratorHistory._checkpoints[length - 1];
if (latest._key <= timepoint) { uint32 latestKey = latest._key;
return latest._value; uint224 latestValue = latest._value;
if (latestKey <= timepoint) {
return latestValue;
} }
// Otherwise, do the binary search // Otherwise, do the binary search