Skip to content

Commit

Permalink
tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
paulwe committed Sep 30, 2023
1 parent 516f234 commit a620473
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions utils/bitmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,11 @@ type bitmapNumber interface {

type Bitmap[T bitmapNumber] struct {
bits []uint64
cap int
}

func NewBitmap[T bitmapNumber](size int) *Bitmap[T] {
c := 1 << bits.Len64(uint64(size+63)/64)
return &Bitmap[T]{
bits: make([]uint64, c),
cap: c,
bits: make([]uint64, 1<<bits.Len64(uint64(size+63)/64)),
}
}

Expand Down Expand Up @@ -88,8 +85,8 @@ func (b *Bitmap[T]) getSlotsAndOffsets(min, max T) (sm int, ls int, rs int, lo i
ls = int(min >> 6) // left slot
rs = int(max >> 6) // right slot

if rs-ls > b.cap {
rs = ls + b.cap
if rs-ls > len(b.bits) {
rs = ls + len(b.bits)
return
}

Expand Down

0 comments on commit a620473

Please sign in to comment.