From d519835ad592efab031917c83483e5dcbeff1c3a Mon Sep 17 00:00:00 2001 From: apocelipes Date: Wed, 30 Aug 2023 14:38:43 +0900 Subject: [PATCH] encoding/asn1: use reflect.TypeFor for known types For #60088 --- src/encoding/asn1/asn1.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/encoding/asn1/asn1.go b/src/encoding/asn1/asn1.go index e7bf793a8272e..9c05871e76ebf 100644 --- a/src/encoding/asn1/asn1.go +++ b/src/encoding/asn1/asn1.go @@ -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