mirror of
https://github.com/tursom/GoCollections.git
synced 2024-12-27 17:10:25 +08:00
improve bloom HashCode operation
This commit is contained in:
parent
df588d7275
commit
6527759d1e
@ -20,9 +20,10 @@ var (
|
|||||||
type (
|
type (
|
||||||
Bloom struct {
|
Bloom struct {
|
||||||
lang.BaseObject
|
lang.BaseObject
|
||||||
m lang.UInt8Array
|
m lang.UInt8Array
|
||||||
k uint
|
k uint
|
||||||
c uint
|
c uint
|
||||||
|
hashCode int32
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -128,7 +129,10 @@ func (b *Bloom) Equals(t lang.Object) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (b *Bloom) HashCode() int32 {
|
func (b *Bloom) HashCode() int32 {
|
||||||
return int32(murmur3.Sum32(b.m.Bytes()))
|
if b.hashCode == 0 {
|
||||||
|
b.hashCode = int32(murmur3.Sum32(b.m.Bytes()))
|
||||||
|
}
|
||||||
|
return b.hashCode
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *Bloom) Merge(t *Bloom) bool {
|
func (b *Bloom) Merge(t *Bloom) bool {
|
||||||
|
Loading…
Reference in New Issue
Block a user