Skip to content

Commit

Permalink
speed up NextClear
Browse files Browse the repository at this point in the history
  • Loading branch information
mhr3 committed Oct 29, 2023
1 parent 9625e3e commit dbb9527
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions bitset.go
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ func (b *BitSet) NextSet(i uint) (uint, bool) {
if b.set[x] != 0 {
return uint(x)*wordSize + trailingZeroes64(b.set[x]), true
}
x = x + 1
x++

}
return 0, false
Expand Down Expand Up @@ -530,9 +530,11 @@ func (b *BitSet) NextClear(i uint) (uint, bool) {
return 0, false
}
for x < len(b.set) {
index = uint(x)*wordSize + trailingZeroes64(^b.set[x])
if b.set[x] != allBits && index < b.length {
return index, true
if b.set[x] != allBits {
index = uint(x)*wordSize + trailingZeroes64(^b.set[x])
if index < b.length {
return index, true
}
}
x++
}
Expand Down

0 comments on commit dbb9527

Please sign in to comment.