improve bloom HashCode operation

This commit is contained in:
tursom 2023-04-25 11:38:44 +08:00
parent df588d7275
commit 6527759d1e

View File

@ -23,6 +23,7 @@ type (
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 {