@@ -1456,25 +1456,24 @@ func (t *rtype) ptrTo() *rtype {
1456
1456
1457
1457
// Create a new ptrType starting with the description
1458
1458
// of an *unsafe.Pointer.
1459
- p = new (ptrType )
1460
1459
var iptr interface {} = (* unsafe .Pointer )(nil )
1461
1460
prototype := * (* * ptrType )(unsafe .Pointer (& iptr ))
1462
- * p = * prototype
1461
+ pp : = * prototype
1463
1462
1464
- p .str = resolveReflectName (newName (s , "" , "" , false ))
1463
+ pp .str = resolveReflectName (newName (s , "" , "" , false ))
1465
1464
1466
1465
// For the type structures linked into the binary, the
1467
1466
// compiler provides a good hash of the string.
1468
1467
// Create a good hash for the new string by using
1469
1468
// the FNV-1 hash's mixing function to combine the
1470
1469
// old hash and the new "*".
1471
- p .hash = fnv1 (t .hash , '*' )
1470
+ pp .hash = fnv1 (t .hash , '*' )
1472
1471
1473
- p .elem = t
1472
+ pp .elem = t
1474
1473
1475
- ptrMap .m [t ] = p
1474
+ ptrMap .m [t ] = & pp
1476
1475
ptrMap .Unlock ()
1477
- return & p .rtype
1476
+ return & pp .rtype
1478
1477
}
1479
1478
1480
1479
// fnv1 incorporates the list of bytes into the hash x using the FNV-1 hash function.
@@ -1852,8 +1851,7 @@ func ChanOf(dir ChanDir, t Type) Type {
1852
1851
// Make a channel type.
1853
1852
var ichan interface {} = (chan unsafe.Pointer )(nil )
1854
1853
prototype := * (* * chanType )(unsafe .Pointer (& ichan ))
1855
- ch := new (chanType )
1856
- * ch = * prototype
1854
+ ch := * prototype
1857
1855
ch .tflag = 0
1858
1856
ch .dir = uintptr (dir )
1859
1857
ch .str = resolveReflectName (newName (s , "" , "" , false ))
@@ -1896,8 +1894,7 @@ func MapOf(key, elem Type) Type {
1896
1894
1897
1895
// Make a map type.
1898
1896
var imap interface {} = (map [unsafe.Pointer ]unsafe.Pointer )(nil )
1899
- mt := new (mapType )
1900
- * mt = * * (* * mapType )(unsafe .Pointer (& imap ))
1897
+ mt := * * (* * mapType )(unsafe .Pointer (& imap ))
1901
1898
mt .str = resolveReflectName (newName (s , "" , "" , false ))
1902
1899
mt .tflag = 0
1903
1900
mt .hash = fnv1 (etyp .hash , 'm' , byte (ktyp .hash >> 24 ), byte (ktyp .hash >> 16 ), byte (ktyp .hash >> 8 ), byte (ktyp .hash ))
@@ -2248,15 +2245,16 @@ func bucketOf(ktyp, etyp *rtype) *rtype {
2248
2245
}
2249
2246
}
2250
2247
2251
- b := new (rtype )
2252
- b .align = ptrSize
2248
+ b := & rtype {
2249
+ align : ptrSize ,
2250
+ size : size ,
2251
+ kind : kind ,
2252
+ ptrdata : ptrdata ,
2253
+ gcdata : gcdata ,
2254
+ }
2253
2255
if overflowPad > 0 {
2254
2256
b .align = 8
2255
2257
}
2256
- b .size = size
2257
- b .ptrdata = ptrdata
2258
- b .kind = kind
2259
- b .gcdata = gcdata
2260
2258
s := "bucket(" + ktyp .String () + "," + etyp .String () + ")"
2261
2259
b .str = resolveReflectName (newName (s , "" , "" , false ))
2262
2260
return b
@@ -2285,8 +2283,7 @@ func SliceOf(t Type) Type {
2285
2283
// Make a slice type.
2286
2284
var islice interface {} = ([]unsafe.Pointer )(nil )
2287
2285
prototype := * (* * sliceType )(unsafe .Pointer (& islice ))
2288
- slice := new (sliceType )
2289
- * slice = * prototype
2286
+ slice := * prototype
2290
2287
slice .tflag = 0
2291
2288
slice .str = resolveReflectName (newName (s , "" , "" , false ))
2292
2289
slice .hash = fnv1 (typ .hash , '[' )
@@ -2830,8 +2827,7 @@ func ArrayOf(count int, elem Type) Type {
2830
2827
// Make an array type.
2831
2828
var iarray interface {} = [1 ]unsafe.Pointer {}
2832
2829
prototype := * (* * arrayType )(unsafe .Pointer (& iarray ))
2833
- array := new (arrayType )
2834
- * array = * prototype
2830
+ array := * prototype
2835
2831
array .str = resolveReflectName (newName (s , "" , "" , false ))
2836
2832
array .hash = fnv1 (typ .hash , '[' )
2837
2833
for n := uint32 (count ); n > 0 ; n >>= 8 {
@@ -3071,13 +3067,14 @@ func funcLayout(t *rtype, rcvr *rtype) (frametype *rtype, argSize, retOffset uin
3071
3067
offset += - offset & (ptrSize - 1 )
3072
3068
3073
3069
// build dummy rtype holding gc program
3074
- x := new (rtype )
3075
- x .align = ptrSize
3070
+ x := & rtype {
3071
+ align : ptrSize ,
3072
+ size : offset ,
3073
+ ptrdata : uintptr (ptrmap .n ) * ptrSize ,
3074
+ }
3076
3075
if runtime .GOARCH == "amd64p32" {
3077
3076
x .align = 8
3078
3077
}
3079
- x .size = offset
3080
- x .ptrdata = uintptr (ptrmap .n ) * ptrSize
3081
3078
if ptrmap .n > 0 {
3082
3079
x .gcdata = & ptrmap .data [0 ]
3083
3080
} else {
0 commit comments