1
0
mirror of https://github.com/golang/go synced 2024-09-29 10:24:34 -06:00

runtime: use fastrand64 in mapiterinit

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>
This commit is contained in:
zhangyunhao 2022-04-19 16:38:04 +08:00 committed by Keith Randall
parent c2d436dcfa
commit 01b8f5e882

View 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))