mirror of
https://github.com/golang/go
synced 2024-11-26 07:38:00 -07:00
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>
This commit is contained in:
parent
352d329c44
commit
0da9eff503
@ -470,13 +470,13 @@ func mapaccess2(t *maptype, h *hmap, key unsafe.Pointer) (unsafe.Pointer, bool)
|
|||||||
}
|
}
|
||||||
hash := t.hasher(key, uintptr(h.hash0))
|
hash := t.hasher(key, uintptr(h.hash0))
|
||||||
m := bucketMask(h.B)
|
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 c := h.oldbuckets; c != nil {
|
||||||
if !h.sameSizeGrow() {
|
if !h.sameSizeGrow() {
|
||||||
// There used to be half as many buckets; mask down one more power of two.
|
// There used to be half as many buckets; mask down one more power of two.
|
||||||
m >>= 1
|
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) {
|
if !evacuated(oldb) {
|
||||||
b = 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))
|
hash := t.hasher(key, uintptr(h.hash0))
|
||||||
m := bucketMask(h.B)
|
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 c := h.oldbuckets; c != nil {
|
||||||
if !h.sameSizeGrow() {
|
if !h.sameSizeGrow() {
|
||||||
// There used to be half as many buckets; mask down one more power of two.
|
// There used to be half as many buckets; mask down one more power of two.
|
||||||
m >>= 1
|
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) {
|
if !evacuated(oldb) {
|
||||||
b = oldb
|
b = oldb
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user