Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Francisco Giordano <frangio.1@gmail.com>
  • Loading branch information
Amxx and frangio committed Jun 10, 2021
1 parent 22ea07c commit 76c3676
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions contracts/utils/structs/BitMaps.sol
Expand Up @@ -10,18 +10,27 @@ library BitMaps {
mapping(uint256 => uint256) _data;
}

/**
* @dev Returns whether the bit at `index` is set.
*/
function get(BitMap storage bitmap, uint256 index) internal view returns (bool) {
uint256 bucket = index / 256;
uint256 mask = 1 << (index % 256);
return bitmap._data[bucket] & mask != 0;
}

/**
* @dev Sets the bit at `index`.
*/
function set(BitMap storage bitmap, uint256 index) internal {
uint256 bucket = index / 256;
uint256 mask = 1 << (index % 256);
bitmap._data[bucket] |= mask;
}

/**
* @dev Unsets the bit at `index`.
*/
function unset(BitMap storage bitmap, uint256 index) internal {
uint256 bucket = index / 256;
uint256 mask = 1 << (index % 256);
Expand Down

0 comments on commit 76c3676

Please sign in to comment.