From 4e4e4eee0419840e391dea9f12a90793532acd5b Mon Sep 17 00:00:00 2001 From: Damian Gryski Date: Wed, 29 Mar 2023 09:38:11 -0700 Subject: [PATCH] runtime: use unsafe.Add() in hashmap code --- src/runtime/hashmap.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/runtime/hashmap.go b/src/runtime/hashmap.go index 2dca2b41..8a902a55 100644 --- a/src/runtime/hashmap.go +++ b/src/runtime/hashmap.go @@ -175,14 +175,14 @@ func hashmapBucketAddrForHash(m *hashmap, hash uint32) *hashmapBucket { //go:inline func hashmapSlotKey(m *hashmap, bucket *hashmapBucket, slot uint8) unsafe.Pointer { slotKeyOffset := unsafe.Sizeof(hashmapBucket{}) + uintptr(m.keySize)*uintptr(slot) - slotKey := unsafe.Pointer(uintptr(unsafe.Pointer(bucket)) + slotKeyOffset) + slotKey := unsafe.Add(unsafe.Pointer(bucket), slotKeyOffset) return slotKey } //go:inline func hashmapSlotValue(m *hashmap, bucket *hashmapBucket, slot uint8) unsafe.Pointer { slotValueOffset := unsafe.Sizeof(hashmapBucket{}) + uintptr(m.keySize)*8 + uintptr(m.valueSize)*uintptr(slot) - slotValue := unsafe.Pointer(uintptr(unsafe.Pointer(bucket)) + slotValueOffset) + slotValue := unsafe.Add(unsafe.Pointer(bucket), slotValueOffset) return slotValue }