reflect: use SliceHeader and StringHeader variant for internal use

These variants uses an unsafe.Pointer instead of uintptr so that the
pointer/non-pointer fields match those of real slices and strings. This
may be necessary in the future once we switch to a precise garbage
collector.
This commit is contained in:
Ayke van Laethem
2021-05-22 18:20:26 +02:00
committed by Ron Evans
parent 711889bc3f
commit c8742e2b96
3 changed files with 35 additions and 20 deletions
+3 -3
View File
@@ -25,9 +25,9 @@ var arrayTypesSidetable byte
// table.
func readStringSidetable(table unsafe.Pointer, index uintptr) string {
nameLen, namePtr := readVarint(unsafe.Pointer(uintptr(table) + index))
return *(*string)(unsafe.Pointer(&StringHeader{
Data: uintptr(namePtr),
Len: nameLen,
return *(*string)(unsafe.Pointer(&stringHeader{
data: namePtr,
len: nameLen,
}))
}