Skip to content

Commit

Permalink
review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
CannibalVox committed Nov 5, 2024
1 parent 063e841 commit 8e4fa49
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
8 changes: 3 additions & 5 deletions bitset.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ func (b *BitSet) Test(i uint) bool {
return b.set[i>>log2WordSize]&(1<<wordsIndex(i)) != 0
}

// Word retrieves bits i through i+63 as a single uint64 value
func (b *BitSet) Word(i uint) uint64 {
// GetWord64AtBit retrieves bits i through i+63 as a single uint64 value
func (b *BitSet) GetWord64AtBit(i uint) uint64 {
firstWordIndex := int(i >> log2WordSize)
subWordIndex := wordsIndex(i)

Expand All @@ -219,9 +219,7 @@ func (b *BitSet) Word(i uint) uint64 {
// The next word, masked to only include the necessary bits and shifted to cover the
// top of the word
if (firstWordIndex + 1) < len(b.set) {
mask := uint64((1 << subWordIndex) - 1)

secondWord = (b.set[firstWordIndex+1] & mask) << uint64(wordSize-subWordIndex)
secondWord = b.set[firstWordIndex+1] << uint64(wordSize-subWordIndex)
}

return firstWord | secondWord
Expand Down
2 changes: 1 addition & 1 deletion bitset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2079,7 +2079,7 @@ func TestWord(t *testing.T) {
for name, testCase := range testCases {
t.Run(name, func(t *testing.T) {
bitSet := From(data)
output := bitSet.Word(testCase.index)
output := bitSet.GetWord64AtBit(testCase.index)

if output != testCase.expected {
t.Errorf("Word should have returned %d for input %d, but returned %d", testCase.expected, testCase.index, output)
Expand Down

0 comments on commit 8e4fa49

Please sign in to comment.