Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
bbloom
Commits
221c7e02
Commit
221c7e02
authored
Aug 23, 2019
by
Steven Allen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: avoid defer
parent
9a1bbb2d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
9 deletions
+12
-9
bbloom.go
bbloom.go
+12
-9
No files found.
bbloom.go
View file @
221c7e02
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment