Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(RingBufferLib): improve lib #175

Merged
merged 3 commits into from
Oct 6, 2021

Conversation

@linear
Copy link

linear bot commented Oct 6, 2021

POOL-1667 RingBufferLib: no need to cast _cardinality

File: https://github.com/pooltogether/pooltogether-contract-tsunami/blob/3e535ef0acccd270324d47c22aa0215773173c25/contracts/libraries/RingBufferLib.sol#L36

In the **mostRecentIndex **function, we pass _cardinality as a uint256 and then we cast it again to uint256 in the return calculation. This is unneeded and can be remove like so:

return (_nextAvailableIndex + _cardinality - 1) % _cardinality;

We could also use the wrap function to handle this calculation:

return wrap(_nextAvailableIndex + _cardinality - 1, _cardinality);

@PierrickGT PierrickGT force-pushed the pool-1667-ringbufferlib-no-need-to-cast branch from d668842 to 51fbb7c Compare October 6, 2021 02:42
@PierrickGT PierrickGT force-pushed the pool-1667-ringbufferlib-no-need-to-cast branch from a23c44e to 78790fa Compare October 6, 2021 04:05
@PierrickGT PierrickGT force-pushed the pool-1667-ringbufferlib-no-need-to-cast branch from 78790fa to 2e231a4 Compare October 6, 2021 04:06
@asselstine asselstine merged commit 7ca195f into master Oct 6, 2021
@asselstine asselstine deleted the pool-1667-ringbufferlib-no-need-to-cast branch October 6, 2021 04:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants