Commit 221c7e02 authored by Steven Allen's avatar Steven Allen

fix: avoid defer

parent 9a1bbb2d
......@@ -148,8 +148,8 @@ func (bl *Bloom) Add(entry []byte) {
// Thread safe: Mutex.Lock the bloomfilter for the time of processing the entry
func (bl *Bloom) AddTS(entry []byte) {
bl.Mtx.Lock()
defer bl.Mtx.Unlock()
bl.Add(entry[:])
bl.Add(entry)
bl.Mtx.Unlock()
}
// Has
......@@ -173,8 +173,9 @@ func (bl *Bloom) Has(entry []byte) bool {
// Thread safe: Mutex.Lock the bloomfilter for the time of processing the entry
func (bl *Bloom) HasTS(entry []byte) bool {
bl.Mtx.RLock()
defer bl.Mtx.RUnlock()
return bl.Has(entry[:])
has := bl.Has(entry[:])
bl.Mtx.RUnlock()
return has
}
// AddIfNotHas
......@@ -200,8 +201,9 @@ func (bl *Bloom) AddIfNotHas(entry []byte) (added bool) {
// returns false if entry was allready registered in the bloomfilter
func (bl *Bloom) AddIfNotHasTS(entry []byte) (added bool) {
bl.Mtx.Lock()
defer bl.Mtx.Unlock()
return bl.AddIfNotHas(entry[:])
added = bl.AddIfNotHas(entry[:])
bl.Mtx.Unlock()
return added
}
// Clear
......@@ -216,8 +218,8 @@ func (bl *Bloom) Clear() {
// ClearTS clears the bloom filter (thread safe).
func (bl *Bloom) ClearTS() {
bl.Mtx.Lock()
defer bl.Mtx.Unlock()
bl.Clear()
bl.Mtx.Unlock()
}
func (bl *Bloom) set(idx uint64) {
......@@ -284,8 +286,9 @@ func (bl *Bloom) FillRatio() float64 {
// FillRatioTS is a thread-save version of FillRatio
func (bl *Bloom) FillRatioTS() float64 {
bl.Mtx.RLock()
defer bl.Mtx.RUnlock()
return bl.FillRatio()
fr := bl.FillRatio()
bl.Mtx.RUnlock()
return fr
}
// // alternative hashFn
......
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