aboutsummaryrefslogtreecommitdiff
path: root/src/runtime
diff options
context:
space:
mode:
authorDan Kortschak <dan@kortschak.io>2021-04-11 14:18:24 +0930
committerKeith Randall <khr@golang.org>2021-04-11 20:41:32 +0000
commit0da9eff5034521ccc51c32ebaad5fae20d8345fe (patch)
tree9b25046b3a04dba3d63d1c6e194a2088ba8c6f87 /src/runtime
parent352d329c44d99b5c6cb325940006ca52f88195f3 (diff)
downloadgo-0da9eff5034521ccc51c32ebaad5fae20d8345fe.tar.xz
runtime: simplify syntax for pointer arithmetic in mapaccess functions
This harmonizes the syntax between mapaccess1 and mapaccess2, and simplifies the code. Change-Id: I6db25ffdc871018d399f9030259894b3994c5793 Reviewed-on: https://go-review.googlesource.com/c/go/+/308951 Reviewed-by: Keith Randall <khr@golang.org> Run-TryBot: Keith Randall <khr@golang.org> Trust: Emmanuel Odeke <emmanuel@orijtech.com> TryBot-Result: Go Bot <gobot@golang.org>
Diffstat (limited to 'src/runtime')
-rw-r--r--src/runtime/map.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/runtime/map.go b/src/runtime/map.go
index 40e19c9294..111db56b01 100644
--- a/src/runtime/map.go
+++ b/src/runtime/map.go
@@ -470,13 +470,13 @@ func mapaccess2(t *maptype, h *hmap, key unsafe.Pointer) (unsafe.Pointer, bool)
}
hash := t.hasher(key, uintptr(h.hash0))
m := bucketMask(h.B)
- b := (*bmap)(unsafe.Pointer(uintptr(h.buckets) + (hash&m)*uintptr(t.bucketsize)))
+ b := (*bmap)(add(h.buckets, (hash&m)*uintptr(t.bucketsize)))
if c := h.oldbuckets; c != nil {
if !h.sameSizeGrow() {
// There used to be half as many buckets; mask down one more power of two.
m >>= 1
}
- oldb := (*bmap)(unsafe.Pointer(uintptr(c) + (hash&m)*uintptr(t.bucketsize)))
+ oldb := (*bmap)(add(c, (hash&m)*uintptr(t.bucketsize)))
if !evacuated(oldb) {
b = oldb
}
@@ -514,13 +514,13 @@ func mapaccessK(t *maptype, h *hmap, key unsafe.Pointer) (unsafe.Pointer, unsafe
}
hash := t.hasher(key, uintptr(h.hash0))
m := bucketMask(h.B)
- b := (*bmap)(unsafe.Pointer(uintptr(h.buckets) + (hash&m)*uintptr(t.bucketsize)))
+ b := (*bmap)(add(h.buckets, (hash&m)*uintptr(t.bucketsize)))
if c := h.oldbuckets; c != nil {
if !h.sameSizeGrow() {
// There used to be half as many buckets; mask down one more power of two.
m >>= 1
}
- oldb := (*bmap)(unsafe.Pointer(uintptr(c) + (hash&m)*uintptr(t.bucketsize)))
+ oldb := (*bmap)(add(c, (hash&m)*uintptr(t.bucketsize)))
if !evacuated(oldb) {
b = oldb
}