cleanup on unmarshall shrink

This commit is contained in:
Todd Gruben 2017-09-15 22:10:48 -05:00
parent 1eb2f8d568
commit 641519acf2

View file

@ -622,6 +622,10 @@ func (b *Bitmap) UnmarshalBinary(data []byte) error {
b.keys = make([]uint64, 0, keyN)
b.containers = make([]*container, 0, keyN)
} else if int(keyN) < len(b.keys) { //shrink
// nil out to allow to be GCed
for i := range b.containers[keyN:] {
b.containers[int(keyN)+i] = nil
}
b.keys = b.keys[:keyN]
b.containers = b.containers[:keyN]
}