]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: use fastrand64 in mapiterinit
authorzhangyunhao <zhangyunhao@bytedance.com>
Tue, 19 Apr 2022 08:38:04 +0000 (16:38 +0800)
committerKeith Randall <khr@golang.org>
Thu, 21 Apr 2022 17:46:15 +0000 (17:46 +0000)
Change-Id: I5698c7576a0f39ae62de7bea64286ac8e578d421
Reviewed-on: https://go-review.googlesource.com/c/go/+/400916
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/runtime/map.go

index e91b25eaec501512170ebe101e3d70aa291b970e..2e513e2d52eadcc8ef72c8c16b0f80b1a0205c62 100644 (file)
@@ -842,9 +842,11 @@ func mapiterinit(t *maptype, h *hmap, it *hiter) {
        }
 
        // decide where to start
-       r := uintptr(fastrand())
+       var r uintptr
        if h.B > 31-bucketCntBits {
-               r += uintptr(fastrand()) << 31
+               r = uintptr(fastrand64())
+       } else {
+               r = uintptr(fastrand())
        }
        it.startBucket = r & bucketMask(h.B)
        it.offset = uint8(r >> h.B & (bucketCnt - 1))