Skip to content

Commit 3fdbd41

Browse files
committed
Change containsInt back
1 parent 3764ee2 commit 3fdbd41

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

packages/shared/pkg/atomicbitset/roaring.go

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ import (
1111
type Roaring struct {
1212
mu sync.RWMutex
1313
bm *roaring.Bitmap
14-
n uint
14+
15+
n uint
1516
}
1617

1718
func NewRoaring(n uint) *Roaring {
@@ -21,15 +22,17 @@ func NewRoaring(n uint) *Roaring {
2122
}
2223
}
2324

24-
func (r *Roaring) Len() uint { return r.n }
25+
func (r *Roaring) Len() uint {
26+
return r.n
27+
}
2528

2629
func (r *Roaring) Has(i uint) bool {
2730
if i >= r.n {
2831
return false
2932
}
3033

3134
r.mu.RLock()
32-
v := r.bm.Contains(uint32(i))
35+
v := r.bm.ContainsInt(int(i))
3336
r.mu.RUnlock()
3437

3538
return v
@@ -39,12 +42,10 @@ func (r *Roaring) HasRange(lo, hi uint) bool {
3942
if lo >= hi {
4043
return true
4144
}
45+
4246
if hi > r.n {
4347
hi = r.n
4448
}
45-
if lo >= hi {
46-
return false
47-
}
4849

4950
r.mu.RLock()
5051
defer r.mu.RUnlock()
@@ -59,13 +60,14 @@ func (r *Roaring) HasRange(lo, hi uint) bool {
5960
}
6061

6162
func (r *Roaring) SetRange(lo, hi uint) {
62-
if hi > r.n {
63-
hi = r.n
64-
}
6563
if lo >= hi {
6664
return
6765
}
6866

67+
if hi > r.n {
68+
hi = r.n
69+
}
70+
6971
r.mu.Lock()
7072
r.bm.AddRange(uint64(lo), uint64(hi))
7173
r.mu.Unlock()

0 commit comments

Comments
 (0)