Skip to content

Commit

Permalink
simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
gaissmai committed Dec 22, 2024
1 parent cc750a0 commit 5512018
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions bitset.go
Original file line number Diff line number Diff line change
Expand Up @@ -1418,18 +1418,13 @@ func (b *BitSet) Select(index uint) uint {

// top detects the top bit set
func (b *BitSet) top() (uint, bool) {
panicIfNull(b)

idx := len(b.set) - 1
for ; idx >= 0 && b.set[idx] == 0; idx-- {
}

// no set bits
if idx < 0 {
return 0, false
for idx := len(b.set) - 1; idx >= 0; idx-- {
if word := b.set[idx]; word != 0 {
return uint(idx<<log2WordSize+bits.Len64(b.set[idx])) - 1, true
}
}

return uint(idx*wordSize+bits.Len64(b.set[idx])) - 1, true
return 0, false
}

// ShiftLeft shifts the bitset like << operation would do.
Expand Down

0 comments on commit 5512018

Please sign in to comment.