fix bitmap.BitwiseEqual bugs

bitmap.BitwiseEqual had a couple of subtle bugs, and the net result
is that if the bitmap you were comparing to had an empty container after
the original bitmap ran out of containers, we'd spuriously report
the container as existing and being... the last container in the original,
actually.

Issues are both that we were grabbing the value from the wrong iterator,
and also that we were iterating twice per loop, and thus could also
have missed a non-empty container immediately following an empty one.
This commit is contained in:
Seebs 2021-03-29 12:22:22 -05:00
parent f1f7bd6327
commit 77f4ff1cfd

View file

@ -6470,16 +6470,14 @@ func (b *Bitmap) BitwiseEqual(c *Bitmap) (bool, error) {
bct++
break
}
bn = biter.Next()
}
for cn {
cn = citer.Next()
ck, cc = biter.Value()
ck, cc = citer.Value()
if cc.N() != 0 {
cct++
break
}
cn = biter.Next()
}
if bn {
return false, fmt.Errorf("container mismatch: %d vs %d containers, first bitmap has extra container %d [%v bits]", bct, cct, bk, bc)