mirror of
https://github.com/tursom/GoCollections.git
synced 2024-12-26 07:50:12 +08:00
improve bloom HashCode operation
This commit is contained in:
parent
df588d7275
commit
6527759d1e
@ -20,9 +20,10 @@ var (
|
||||
type (
|
||||
Bloom struct {
|
||||
lang.BaseObject
|
||||
m lang.UInt8Array
|
||||
k uint
|
||||
c uint
|
||||
m lang.UInt8Array
|
||||
k uint
|
||||
c uint
|
||||
hashCode int32
|
||||
}
|
||||
)
|
||||
|
||||
@ -128,7 +129,10 @@ func (b *Bloom) Equals(t lang.Object) bool {
|
||||
}
|
||||
|
||||
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 {
|
||||
|
Loading…
Reference in New Issue
Block a user