@@ -18,7 +18,6 @@ package v2
1818import (
1919 "errors"
2020 "hash"
21- "sync"
2221)
2322
2423var (
2726
2827// Filter is an opaque Bloom filter type
2928type Filter struct {
30- lock sync.RWMutex
3129 bits []uint64
3230 keys []uint64
3331 m uint64 // number of bits the "bits" field should recognize
@@ -58,8 +56,6 @@ const rotation = 17
5856// Adds an already hashes item to the filter.
5957// Identical to Add (but slightly faster)
6058func (f * Filter ) AddHash (hash uint64 ) {
61- f .lock .Lock ()
62- defer f .lock .Unlock ()
6359 var (
6460 i uint64
6561 )
@@ -74,8 +70,6 @@ func (f *Filter) AddHash(hash uint64) {
7470// ContainsHash tests if f contains the (already hashed) key
7571// Identical to Contains but slightly faster
7672func (f * Filter ) ContainsHash (hash uint64 ) bool {
77- f .lock .RLock ()
78- defer f .lock .RUnlock ()
7973 var (
8074 i uint64
8175 r = uint64 (1 )
@@ -97,9 +91,6 @@ func (f *Filter) Contains(v hash.Hash64) bool {
9791
9892// Copy f to a new Bloom filter
9993func (f * Filter ) Copy () (* Filter , error ) {
100- f .lock .RLock ()
101- defer f .lock .RUnlock ()
102-
10394 out , err := f .NewCompatible ()
10495 if err != nil {
10596 return nil , err
@@ -115,9 +106,6 @@ func (f *Filter) UnionInPlace(f2 *Filter) error {
115106 return errors .New ("incompatible bloom filters" )
116107 }
117108
118- f .lock .Lock ()
119- defer f .lock .Unlock ()
120-
121109 for i , bitword := range f2 .bits {
122110 f .bits [i ] |= bitword
123111 }
@@ -132,9 +120,6 @@ func (f *Filter) Union(f2 *Filter) (out *Filter, err error) {
132120 return nil , errors .New ("incompatible bloom filters" )
133121 }
134122
135- f .lock .RLock ()
136- defer f .lock .RUnlock ()
137-
138123 out , err = f .NewCompatible ()
139124 if err != nil {
140125 return nil , err
0 commit comments