mirror of
https://github.com/golang/go
synced 2024-11-17 05:44:52 -07:00
hash/maphash: use fastrand64 in MakeSeed
Change-Id: I5ccbcea4c53658136b25ca608faec19eeec2e908 Reviewed-on: https://go-review.googlesource.com/c/go/+/400915 Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Wayne Zuo <wdvxdr@golangcn.org> TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
parent
b34838913d
commit
c2d436dcfa
@ -252,21 +252,20 @@ func (h *Hash) Sum64() uint64 {
|
|||||||
|
|
||||||
// MakeSeed returns a new random seed.
|
// MakeSeed returns a new random seed.
|
||||||
func MakeSeed() Seed {
|
func MakeSeed() Seed {
|
||||||
var s1, s2 uint64
|
var s uint64
|
||||||
for {
|
for {
|
||||||
s1 = uint64(runtime_fastrand())
|
s = runtime_fastrand64()
|
||||||
s2 = uint64(runtime_fastrand())
|
|
||||||
// We use seed 0 to indicate an uninitialized seed/hash,
|
// We use seed 0 to indicate an uninitialized seed/hash,
|
||||||
// so keep trying until we get a non-zero seed.
|
// so keep trying until we get a non-zero seed.
|
||||||
if s1|s2 != 0 {
|
if s != 0 {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Seed{s: s1<<32 + s2}
|
return Seed{s: s}
|
||||||
}
|
}
|
||||||
|
|
||||||
//go:linkname runtime_fastrand runtime.fastrand
|
//go:linkname runtime_fastrand64 runtime.fastrand64
|
||||||
func runtime_fastrand() uint32
|
func runtime_fastrand64() uint64
|
||||||
|
|
||||||
func rthash(ptr *byte, len int, seed uint64) uint64 {
|
func rthash(ptr *byte, len int, seed uint64) uint64 {
|
||||||
if len == 0 {
|
if len == 0 {
|
||||||
|
Loading…
Reference in New Issue
Block a user