]> Cypherpunks repositories - gostls13.git/commitdiff
encoding/asn1: use reflect.TypeFor for known types
authorapocelipes <seve3r@outlook.com>
Wed, 30 Aug 2023 05:51:23 +0000 (05:51 +0000)
committerGopher Robot <gobot@golang.org>
Wed, 30 Aug 2023 19:53:38 +0000 (19:53 +0000)
For #60088

Change-Id: I4b2a5c6c59ef26361f343052a4ddaabde5d3bc94
GitHub-Last-Rev: d519835ad592efab031917c83483e5dcbeff1c3a
GitHub-Pull-Request: golang/go#62370
Reviewed-on: https://go-review.googlesource.com/c/go/+/524259
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>

src/encoding/asn1/asn1.go

index e7bf793a8272e60983bdee48254c0e77d9238f1c..9c05871e76ebf448ca6d337b950ea77a93112195 100644 (file)
@@ -656,14 +656,14 @@ func parseSequenceOf(bytes []byte, sliceType reflect.Type, elemType reflect.Type
 }
 
 var (
-       bitStringType        = reflect.TypeOf(BitString{})
-       objectIdentifierType = reflect.TypeOf(ObjectIdentifier{})
-       enumeratedType       = reflect.TypeOf(Enumerated(0))
-       flagType             = reflect.TypeOf(Flag(false))
-       timeType             = reflect.TypeOf(time.Time{})
-       rawValueType         = reflect.TypeOf(RawValue{})
-       rawContentsType      = reflect.TypeOf(RawContent(nil))
-       bigIntType           = reflect.TypeOf((*big.Int)(nil))
+       bitStringType        = reflect.TypeFor[BitString]()
+       objectIdentifierType = reflect.TypeFor[ObjectIdentifier]()
+       enumeratedType       = reflect.TypeFor[Enumerated]()
+       flagType             = reflect.TypeFor[Flag]()
+       timeType             = reflect.TypeFor[time.Time]()
+       rawValueType         = reflect.TypeFor[RawValue]()
+       rawContentsType      = reflect.TypeFor[RawContent]()
+       bigIntType           = reflect.TypeFor[*big.Int]()
 )
 
 // invalidLength reports whether offset + length > sliceLength, or if the