From f051ec64639b83faabcfe766ff078072def3c2aa Mon Sep 17 00:00:00 2001 From: Jamie Liu Date: Wed, 17 Feb 2021 17:39:24 -0800 Subject: Add gohacks.Slice/StringHeader. See https://github.com/golang/go/issues/19367 for rationale. Note that the upstream decision arrived at in that thread, while useful for some of our use cases, doesn't account for all of our SliceHeader use cases (we often use SliceHeader to extract pointers from slices in a way that avoids bounds checking and/or handles nil slices correctly) and also doesn't exist yet. PiperOrigin-RevId: 358071574 --- pkg/sync/generic_atomicptrmap_unsafe.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'pkg/sync/generic_atomicptrmap_unsafe.go') diff --git a/pkg/sync/generic_atomicptrmap_unsafe.go b/pkg/sync/generic_atomicptrmap_unsafe.go index c70dda6dd..3e98cb309 100644 --- a/pkg/sync/generic_atomicptrmap_unsafe.go +++ b/pkg/sync/generic_atomicptrmap_unsafe.go @@ -17,8 +17,6 @@ package atomicptrmap import ( - "reflect" - "runtime" "sync/atomic" "unsafe" @@ -372,9 +370,8 @@ func (shard *apmShard) rehash(oldSlots unsafe.Pointer) { // Allocate the new table. newSlotsSlice := make([]apmSlot, newSize) - newSlotsReflect := (*reflect.SliceHeader)(unsafe.Pointer(&newSlotsSlice)) - newSlots := unsafe.Pointer(newSlotsReflect.Data) - runtime.KeepAlive(newSlotsSlice) + newSlotsHeader := (*gohacks.SliceHeader)(unsafe.Pointer(&newSlotsSlice)) + newSlots := newSlotsHeader.Data newMask := newSize - 1 // Start a writer critical section now so that racing users of the old -- cgit v1.2.3