// Create a new ptrType starting with the description
// of an *unsafe.Pointer.
- p = new(ptrType)
var iptr interface{} = (*unsafe.Pointer)(nil)
prototype := *(**ptrType)(unsafe.Pointer(&iptr))
- *p = *prototype
+ pp := *prototype
- p.str = resolveReflectName(newName(s, "", "", false))
+ pp.str = resolveReflectName(newName(s, "", "", false))
// For the type structures linked into the binary, the
// compiler provides a good hash of the string.
// Create a good hash for the new string by using
// the FNV-1 hash's mixing function to combine the
// old hash and the new "*".
- p.hash = fnv1(t.hash, '*')
+ pp.hash = fnv1(t.hash, '*')
- p.elem = t
+ pp.elem = t
- ptrMap.m[t] = p
+ ptrMap.m[t] = &pp
ptrMap.Unlock()
- return &p.rtype
+ return &pp.rtype
}
// fnv1 incorporates the list of bytes into the hash x using the FNV-1 hash function.
// Make a channel type.
var ichan interface{} = (chan unsafe.Pointer)(nil)
prototype := *(**chanType)(unsafe.Pointer(&ichan))
- ch := new(chanType)
- *ch = *prototype
+ ch := *prototype
ch.tflag = 0
ch.dir = uintptr(dir)
ch.str = resolveReflectName(newName(s, "", "", false))
// Make a map type.
var imap interface{} = (map[unsafe.Pointer]unsafe.Pointer)(nil)
- mt := new(mapType)
- *mt = **(**mapType)(unsafe.Pointer(&imap))
+ mt := **(**mapType)(unsafe.Pointer(&imap))
mt.str = resolveReflectName(newName(s, "", "", false))
mt.tflag = 0
mt.hash = fnv1(etyp.hash, 'm', byte(ktyp.hash>>24), byte(ktyp.hash>>16), byte(ktyp.hash>>8), byte(ktyp.hash))
}
}
- b := new(rtype)
- b.align = ptrSize
+ b := &rtype{
+ align: ptrSize,
+ size: size,
+ kind: kind,
+ ptrdata: ptrdata,
+ gcdata: gcdata,
+ }
if overflowPad > 0 {
b.align = 8
}
- b.size = size
- b.ptrdata = ptrdata
- b.kind = kind
- b.gcdata = gcdata
s := "bucket(" + ktyp.String() + "," + etyp.String() + ")"
b.str = resolveReflectName(newName(s, "", "", false))
return b
// Make a slice type.
var islice interface{} = ([]unsafe.Pointer)(nil)
prototype := *(**sliceType)(unsafe.Pointer(&islice))
- slice := new(sliceType)
- *slice = *prototype
+ slice := *prototype
slice.tflag = 0
slice.str = resolveReflectName(newName(s, "", "", false))
slice.hash = fnv1(typ.hash, '[')
// Make an array type.
var iarray interface{} = [1]unsafe.Pointer{}
prototype := *(**arrayType)(unsafe.Pointer(&iarray))
- array := new(arrayType)
- *array = *prototype
+ array := *prototype
array.str = resolveReflectName(newName(s, "", "", false))
array.hash = fnv1(typ.hash, '[')
for n := uint32(count); n > 0; n >>= 8 {
offset += -offset & (ptrSize - 1)
// build dummy rtype holding gc program
- x := new(rtype)
- x.align = ptrSize
+ x := &rtype{
+ align: ptrSize,
+ size: offset,
+ ptrdata: uintptr(ptrmap.n) * ptrSize,
+ }
if runtime.GOARCH == "amd64p32" {
x.align = 8
}
- x.size = offset
- x.ptrdata = uintptr(ptrmap.n) * ptrSize
if ptrmap.n > 0 {
x.gcdata = &ptrmap.data[0]
} else {