bits-and-blooms/bitset

`Equal()` panics when called with bitsets with different `set` lengths

omerfirmak opened this issue · 1 comments

bitset/bitset.go

Lines 603 to 615 in 312c8c2

if b.length != c.length {
return false
}
if b.length == 0 { // if they have both length == 0, then could have nil set
return true
}
// testing for equality shoud not transform the bitset (no call to safeSet)
for p, v := range b.set {
if c.set[p] != v {
return false
}
}

even tho b.length == c.length, len(b.set) and len(c.set) could be different.

Equal should check if wordsNeeded(b.length) number of words are equal.

I agree.