byte[] buffer = (*byte)malloc(1024)
int[] meta = (int *)(void *)(buffer + 512)
meta[0] = 0
meta[1] = 1
...import "unsafe"
var buffer []byte = new([]byte, 1024)
???var firstMetaAdress uintptr = uinptr(unsafe.Pointer(&buffer [512]))*( (*int32) (unsafe.Pointer(firstMetaAdress) ) )= 0
*( (*int32) (unsafe.Pointer(firstMetaAdress + 4) ) )= 1
...import "unsafe"
const maxSize = 2048
var size = 1024
var buffer []byte = new([]byte, size)
p := (*[maxSize/4/2]int32)(unsafe.Pointer(&buffer[len(buffer/2)]))
p[0] =
...
p[size/4/2] = -j
Yep, it is feasible. But there are overheads transforming between 4 bytes and 1 int. If bypassing the type system is permitted, the compiler system can use the low-level instructions to transfer 4 bytes to 1 integer.
It is feasible. As i said above, it need some computing overheads to transform between bytes and integers.If i want pursue exceeding optimization, i think the issue is worth talking.
Yep, it is feasible. But there are overheads transforming between 4 bytes and 1 int. If bypassing the type system is permitted, the compiler system can use the low-level instructions to transfer 4 bytes to 1 integer.C language can do this by transfer *byte to *int through intermediate type *void. Then getting a integer just need a instrcution.