From: zhangyunhao Date: Tue, 19 Apr 2022 08:38:04 +0000 (+0800) Subject: runtime: use fastrand64 in mapiterinit X-Git-Tag: go1.19beta1~606 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=01b8f5e8821eac0e3456d6200b351629fd3752f4;p=gostls13.git runtime: use fastrand64 in mapiterinit Change-Id: I5698c7576a0f39ae62de7bea64286ac8e578d421 Reviewed-on: https://go-review.googlesource.com/c/go/+/400916 Reviewed-by: Keith Randall Reviewed-by: Keith Randall Reviewed-by: Ian Lance Taylor Run-TryBot: Wayne Zuo TryBot-Result: Gopher Robot --- diff --git a/src/runtime/map.go b/src/runtime/map.go index e91b25eaec..2e513e2d52 100644 --- a/src/runtime/map.go +++ b/src/runtime/map.go @@ -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))