From: Matthew Dempsky Date: Fri, 16 Oct 2015 23:21:26 +0000 (-0700) Subject: runtime: remove some unnecessary unsafe code in mfixalloc X-Git-Tag: go1.6beta1~823 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=4562784baed3b64e4ffdd3b2ea3c6d4b11391335;p=gostls13.git runtime: remove some unnecessary unsafe code in mfixalloc Change-Id: Ie9ea4af4315a4d0eb69d0569726bb3eca2b397af Reviewed-on: https://go-review.googlesource.com/16005 Reviewed-by: Brad Fitzpatrick --- diff --git a/src/runtime/mfixalloc.go b/src/runtime/mfixalloc.go index ec926323d8..57a136d06b 100644 --- a/src/runtime/mfixalloc.go +++ b/src/runtime/mfixalloc.go @@ -20,7 +20,7 @@ import "unsafe" // smashed by freeing and reallocating. type fixalloc struct { size uintptr - first unsafe.Pointer // go func(unsafe.pointer, unsafe.pointer); f(arg, p) called first time p is returned + first func(arg, p unsafe.Pointer) // called first time p is returned arg unsafe.Pointer list *mlink chunk *byte @@ -40,9 +40,9 @@ type mlink struct { // Initialize f to allocate objects of the given size, // using the allocator to obtain chunks of memory. -func fixAlloc_Init(f *fixalloc, size uintptr, first func(unsafe.Pointer, unsafe.Pointer), arg unsafe.Pointer, stat *uint64) { +func fixAlloc_Init(f *fixalloc, size uintptr, first func(arg, p unsafe.Pointer), arg unsafe.Pointer, stat *uint64) { f.size = size - f.first = *(*unsafe.Pointer)(unsafe.Pointer(&first)) + f.first = first f.arg = arg f.list = nil f.chunk = nil @@ -70,8 +70,7 @@ func fixAlloc_Alloc(f *fixalloc) unsafe.Pointer { v := unsafe.Pointer(f.chunk) if f.first != nil { - fn := *(*func(unsafe.Pointer, unsafe.Pointer))(unsafe.Pointer(&f.first)) - fn(f.arg, v) + f.first(f.arg, v) } f.chunk = (*byte)(add(unsafe.Pointer(f.chunk), f.size)) f.nchunk -= uint32(f.size)