Unverified Commit 627bb99e authored by Steven Allen's avatar Steven Allen Committed by GitHub

Merge pull request #6 from ipfs/fix/odd-ends

fix clear performance
parents b3466c29 84e8303a
Pipeline #87 failed with stages
in 0 seconds
......@@ -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