cmd/protoc-gen-go: change some arrays to slices to save bytes
Using arrays in the generated reflection information adds unnecessary
eq and hash functions being added to the package. Change to slices
to reduce bloat.
Change-Id: I1a4f6d59021644d93dd6c24679b9233141e89a75
Reviewed-on: https://go-review.googlesource.com/c/164640
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
diff --git a/cmd/protoc-gen-go/testdata/proto2/enum.pb.go b/cmd/protoc-gen-go/testdata/proto2/enum.pb.go
index 96dd21b..866e157 100644
--- a/cmd/protoc-gen-go/testdata/proto2/enum.pb.go
+++ b/cmd/protoc-gen-go/testdata/proto2/enum.pb.go
@@ -446,8 +446,8 @@
var File_proto2_enum_proto protoreflect.FileDescriptor
-var xxx_File_proto2_enum_proto_enumTypes [6]protoreflect.EnumType
-var xxx_File_proto2_enum_proto_messageTypes [2]protoimpl.MessageType
+var xxx_File_proto2_enum_proto_enumTypes = make([]protoreflect.EnumType, 6)
+var xxx_File_proto2_enum_proto_messageTypes = make([]protoimpl.MessageType, 2)
var xxx_File_proto2_enum_proto_goTypes = []interface{}{
(EnumType1)(0), // 0: goproto.protoc.proto2.EnumType1
(EnumType2)(0), // 1: goproto.protoc.proto2.EnumType2
@@ -464,16 +464,16 @@
}
func init() {
- var messageTypes [2]protoreflect.MessageType
+ messageTypes := make([]protoreflect.MessageType, 2)
File_proto2_enum_proto = protoimpl.FileBuilder{
RawDescriptor: xxx_File_proto2_enum_proto_rawdesc,
GoTypes: xxx_File_proto2_enum_proto_goTypes,
DependencyIndexes: xxx_File_proto2_enum_proto_depIdxs,
- EnumOutputTypes: xxx_File_proto2_enum_proto_enumTypes[:],
- MessageOutputTypes: messageTypes[:],
+ EnumOutputTypes: xxx_File_proto2_enum_proto_enumTypes,
+ MessageOutputTypes: messageTypes,
}.Init()
messageGoTypes := xxx_File_proto2_enum_proto_goTypes[6:][:2]
- for i, mt := range messageTypes[:] {
+ for i, mt := range messageTypes {
xxx_File_proto2_enum_proto_messageTypes[i].GoType = reflect.TypeOf(messageGoTypes[i])
xxx_File_proto2_enum_proto_messageTypes[i].PBType = mt
}