1
0
mirror of https://github.com/charlienet/go-mixed.git synced 2025-07-18 00:22:41 +08:00

优化range引用

This commit is contained in:
2022-07-04 12:01:44 +08:00
parent 44304f5b16
commit 886723997e
8 changed files with 143 additions and 12 deletions

View File

@ -26,7 +26,8 @@ func NewBloomFilter() *BloomFilter {
}
func (bf *BloomFilter) Add(value string) {
for _, f := range bf.funcs {
funcs := bf.funcs[:]
for _, f := range funcs {
bf.set.Set(f.hash(value))
}
}
@ -36,7 +37,9 @@ func (bf *BloomFilter) Contains(value string) bool {
return false
}
ret := true
for _, f := range bf.funcs {
funcs := bf.funcs[:]
for _, f := range funcs {
ret = ret && bf.set.Test(f.hash(value))
}
return ret