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
51623e51
Commit
51623e51
authored
Aug 23, 2019
by
Steven Allen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avoid passing slices by reference
parent
371f9656
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
4 deletions
+4
-4
bbloom.go
bbloom.go
+4
-4
No files found.
bbloom.go
View file @
51623e51
...
...
@@ -81,13 +81,13 @@ func New(params ...float64) (bloomfilter *Bloom, err error) {
// NewWithBoolset
// takes a []byte slice and number of locs per entry
// returns the bloomfilter with a bitset populated according to the input []byte
func
NewWithBoolset
(
bs
*
[]
byte
,
locs
uint64
)
(
bloomfilter
*
Bloom
)
{
bloomfilter
,
err
:=
New
(
float64
(
len
(
*
bs
)
<<
3
),
float64
(
locs
))
func
NewWithBoolset
(
bs
[]
byte
,
locs
uint64
)
(
bloomfilter
*
Bloom
)
{
bloomfilter
,
err
:=
New
(
float64
(
len
(
bs
)
<<
3
),
float64
(
locs
))
if
err
!=
nil
{
panic
(
err
)
// Should never happen
}
for
i
:=
range
bloomfilter
.
bitset
{
bloomfilter
.
bitset
[
i
]
=
binary
.
BigEndian
.
Uint64
((
*
bs
)[
i
<<
3
:
])
bloomfilter
.
bitset
[
i
]
=
binary
.
BigEndian
.
Uint64
((
bs
)[
i
<<
3
:
])
}
return
bloomfilter
}
...
...
@@ -270,7 +270,7 @@ func JSONUnmarshal(dbData []byte) *Bloom {
json
.
Unmarshal
(
dbData
,
&
bloomImEx
)
buf
:=
bytes
.
NewBuffer
(
bloomImEx
.
FilterSet
)
bs
:=
buf
.
Bytes
()
bf
:=
NewWithBoolset
(
&
bs
,
bloomImEx
.
SetLocs
)
bf
:=
NewWithBoolset
(
bs
,
bloomImEx
.
SetLocs
)
return
bf
}
...
...
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