]> Cypherpunks.ru repositories - gostls13.git/commitdiff
hash/maphash: use fastrand64 in MakeSeed
authorzhangyunhao <zhangyunhao@bytedance.com>
Tue, 19 Apr 2022 06:44:03 +0000 (14:44 +0800)
committerKeith Randall <khr@golang.org>
Thu, 21 Apr 2022 17:46:04 +0000 (17:46 +0000)
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>

src/hash/maphash/maphash.go

index 783690ea00f998f9044f1307faa5f759dd9f44a2..dfacd021db25d9c725248fff1a3631a554758786 100644 (file)
@@ -252,21 +252,20 @@ func (h *Hash) Sum64() uint64 {
 
 // MakeSeed returns a new random seed.
 func MakeSeed() Seed {
-       var s1, s2 uint64
+       var s uint64
        for {
-               s1 = uint64(runtime_fastrand())
-               s2 = uint64(runtime_fastrand())
+               s = runtime_fastrand64()
                // We use seed 0 to indicate an uninitialized seed/hash,
                // so keep trying until we get a non-zero seed.
-               if s1|s2 != 0 {
+               if s != 0 {
                        break
                }
        }
-       return Seed{s: s1<<32 + s2}
+       return Seed{s: s}
 }
 
-//go:linkname runtime_fastrand runtime.fastrand
-func runtime_fastrand() uint32
+//go:linkname runtime_fastrand64 runtime.fastrand64
+func runtime_fastrand64() uint64
 
 func rthash(ptr *byte, len int, seed uint64) uint64 {
        if len == 0 {