Commit 84e8303a authored by Steven Allen's avatar Steven Allen

fix clear performance

parent b3466c29
......@@ -162,6 +162,7 @@ func (bl *Bloom) Has(entry []byte) bool {
res = res && bl.isSet((h+i*l)&bl.size)
// Branching here (early escape) is not worth it
// This is my conclusion from benchmarks
// (prevents loop unrolling)
// if !res {
// return false
// }
......@@ -209,8 +210,9 @@ func (bl *Bloom) AddIfNotHasTS(entry []byte) (added bool) {
// Clear
// resets the Bloom filter
func (bl *Bloom) Clear() {
for i, _ := range (*bl).bitset {
bl.bitset[i] = 0
bs := bl.bitset // important performance optimization.
for i := range bs {
bs[i] = 0
}
bl.content = 0
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment