diff --git a/plugin/unmarshal/unmarshal.go b/plugin/unmarshal/unmarshal.go index 53265a53cf..d7cfb59400 100644 --- a/plugin/unmarshal/unmarshal.go +++ b/plugin/unmarshal/unmarshal.go @@ -1100,20 +1100,32 @@ func (p *unmarshal) Generate(file *generator.FileDescriptor) { p.Out() p.P(`}`) - var fixedTypeSizeBytes int + p.P(`var elementCount int`) switch *field.Type { case descriptor.FieldDescriptorProto_TYPE_DOUBLE, descriptor.FieldDescriptorProto_TYPE_FIXED64, descriptor.FieldDescriptorProto_TYPE_SFIXED64: - fixedTypeSizeBytes = 8 + p.P(`elementCount = packedLen/`, 8) case descriptor.FieldDescriptorProto_TYPE_FLOAT, descriptor.FieldDescriptorProto_TYPE_FIXED32, descriptor.FieldDescriptorProto_TYPE_SFIXED32: - fixedTypeSizeBytes = 4 - } - if fixedTypeSizeBytes != 0 { - p.P(`if len(m.`, fieldname, `) == 0 {`) + p.P(`elementCount = packedLen/`, 4) + case descriptor.FieldDescriptorProto_TYPE_INT64, descriptor.FieldDescriptorProto_TYPE_UINT64, descriptor.FieldDescriptorProto_TYPE_INT32, descriptor.FieldDescriptorProto_TYPE_UINT32, descriptor.FieldDescriptorProto_TYPE_SINT32, descriptor.FieldDescriptorProto_TYPE_SINT64: + p.P(`var count int`) + p.P(`for _, integer := range dAtA {`) + p.In() + p.P(`if integer < 128 {`) p.In() - p.P(`m.`, fieldname, ` = make([]`, p.noStarOrSliceType(message, field), `, 0, packedLen/`, fixedTypeSizeBytes, `)`) + p.P(`count++`) + p.Out() + p.P(`}`) p.Out() p.P(`}`) + p.P(`elementCount = count`) + case descriptor.FieldDescriptorProto_TYPE_BOOL: + p.P(`elementCount = packedLen`) } + p.P(`if elementCount != 0 && len(m.`, fieldname, `) == 0 {`) + p.In() + p.P(`m.`, fieldname, ` = make([]`, p.noStarOrSliceType(message, field), `, 0, elementCount)`) + p.Out() + p.P(`}`) p.P(`for iNdEx < postIndex {`) p.In() diff --git a/test/casttype/combos/both/casttype.pb.go b/test/casttype/combos/both/casttype.pb.go index d70e22a98f..b6d8424bd6 100644 --- a/test/casttype/combos/both/casttype.pb.go +++ b/test/casttype/combos/both/casttype.pb.go @@ -1863,6 +1863,17 @@ func (m *Castaway) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.MyUint64S) == 0 { + m.MyUint64S = make([]github_com_gogo_protobuf_test_casttype.MyUint64Type, 0, elementCount) + } for iNdEx < postIndex { var v github_com_gogo_protobuf_test_casttype.MyUint64Type for shift := uint(0); ; shift += 7 { diff --git a/test/casttype/combos/unmarshaler/casttype.pb.go b/test/casttype/combos/unmarshaler/casttype.pb.go index 20743e89aa..aaf3601438 100644 --- a/test/casttype/combos/unmarshaler/casttype.pb.go +++ b/test/casttype/combos/unmarshaler/casttype.pb.go @@ -1641,6 +1641,17 @@ func (m *Castaway) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.MyUint64S) == 0 { + m.MyUint64S = make([]github_com_gogo_protobuf_test_casttype.MyUint64Type, 0, elementCount) + } for iNdEx < postIndex { var v github_com_gogo_protobuf_test_casttype.MyUint64Type for shift := uint(0); ; shift += 7 { diff --git a/test/combos/both/thetest.pb.go b/test/combos/both/thetest.pb.go index c07c2a058c..7b4cfd3c61 100644 --- a/test/combos/both/thetest.pb.go +++ b/test/combos/both/thetest.pb.go @@ -32179,8 +32179,10 @@ func (m *NidRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field1) == 0 { - m.Field1 = make([]float64, 0, packedLen/8) + var elementCount int + elementCount = packedLen / 8 + if elementCount != 0 && len(m.Field1) == 0 { + m.Field1 = make([]float64, 0, elementCount) } for iNdEx < postIndex { var v uint64 @@ -32228,8 +32230,10 @@ func (m *NidRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field2) == 0 { - m.Field2 = make([]float32, 0, packedLen/4) + var elementCount int + elementCount = packedLen / 4 + if elementCount != 0 && len(m.Field2) == 0 { + m.Field2 = make([]float32, 0, elementCount) } for iNdEx < postIndex { var v uint32 @@ -32285,6 +32289,17 @@ func (m *NidRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field3) == 0 { + m.Field3 = make([]int32, 0, elementCount) + } for iNdEx < postIndex { var v int32 for shift := uint(0); ; shift += 7 { @@ -32347,6 +32362,17 @@ func (m *NidRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field4) == 0 { + m.Field4 = make([]int64, 0, elementCount) + } for iNdEx < postIndex { var v int64 for shift := uint(0); ; shift += 7 { @@ -32409,6 +32435,17 @@ func (m *NidRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field5) == 0 { + m.Field5 = make([]uint32, 0, elementCount) + } for iNdEx < postIndex { var v uint32 for shift := uint(0); ; shift += 7 { @@ -32471,6 +32508,17 @@ func (m *NidRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field6) == 0 { + m.Field6 = make([]uint64, 0, elementCount) + } for iNdEx < postIndex { var v uint64 for shift := uint(0); ; shift += 7 { @@ -32534,6 +32582,17 @@ func (m *NidRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field7) == 0 { + m.Field7 = make([]int32, 0, elementCount) + } for iNdEx < postIndex { var v int32 for shift := uint(0); ; shift += 7 { @@ -32598,6 +32657,17 @@ func (m *NidRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field8) == 0 { + m.Field8 = make([]int64, 0, elementCount) + } for iNdEx < postIndex { var v uint64 for shift := uint(0); ; shift += 7 { @@ -32652,8 +32722,10 @@ func (m *NidRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field9) == 0 { - m.Field9 = make([]uint32, 0, packedLen/4) + var elementCount int + elementCount = packedLen / 4 + if elementCount != 0 && len(m.Field9) == 0 { + m.Field9 = make([]uint32, 0, elementCount) } for iNdEx < postIndex { var v uint32 @@ -32699,8 +32771,10 @@ func (m *NidRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field10) == 0 { - m.Field10 = make([]int32, 0, packedLen/4) + var elementCount int + elementCount = packedLen / 4 + if elementCount != 0 && len(m.Field10) == 0 { + m.Field10 = make([]int32, 0, elementCount) } for iNdEx < postIndex { var v int32 @@ -32746,8 +32820,10 @@ func (m *NidRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field11) == 0 { - m.Field11 = make([]uint64, 0, packedLen/8) + var elementCount int + elementCount = packedLen / 8 + if elementCount != 0 && len(m.Field11) == 0 { + m.Field11 = make([]uint64, 0, elementCount) } for iNdEx < postIndex { var v uint64 @@ -32793,8 +32869,10 @@ func (m *NidRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field12) == 0 { - m.Field12 = make([]int64, 0, packedLen/8) + var elementCount int + elementCount = packedLen / 8 + if elementCount != 0 && len(m.Field12) == 0 { + m.Field12 = make([]int64, 0, elementCount) } for iNdEx < postIndex { var v int64 @@ -32849,6 +32927,11 @@ func (m *NidRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + elementCount = packedLen + if elementCount != 0 && len(m.Field13) == 0 { + m.Field13 = make([]bool, 0, elementCount) + } for iNdEx < postIndex { var v int for shift := uint(0); ; shift += 7 { @@ -33012,8 +33095,10 @@ func (m *NinRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field1) == 0 { - m.Field1 = make([]float64, 0, packedLen/8) + var elementCount int + elementCount = packedLen / 8 + if elementCount != 0 && len(m.Field1) == 0 { + m.Field1 = make([]float64, 0, elementCount) } for iNdEx < postIndex { var v uint64 @@ -33061,8 +33146,10 @@ func (m *NinRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field2) == 0 { - m.Field2 = make([]float32, 0, packedLen/4) + var elementCount int + elementCount = packedLen / 4 + if elementCount != 0 && len(m.Field2) == 0 { + m.Field2 = make([]float32, 0, elementCount) } for iNdEx < postIndex { var v uint32 @@ -33118,6 +33205,17 @@ func (m *NinRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field3) == 0 { + m.Field3 = make([]int32, 0, elementCount) + } for iNdEx < postIndex { var v int32 for shift := uint(0); ; shift += 7 { @@ -33180,6 +33278,17 @@ func (m *NinRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field4) == 0 { + m.Field4 = make([]int64, 0, elementCount) + } for iNdEx < postIndex { var v int64 for shift := uint(0); ; shift += 7 { @@ -33242,6 +33351,17 @@ func (m *NinRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field5) == 0 { + m.Field5 = make([]uint32, 0, elementCount) + } for iNdEx < postIndex { var v uint32 for shift := uint(0); ; shift += 7 { @@ -33304,6 +33424,17 @@ func (m *NinRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field6) == 0 { + m.Field6 = make([]uint64, 0, elementCount) + } for iNdEx < postIndex { var v uint64 for shift := uint(0); ; shift += 7 { @@ -33367,6 +33498,17 @@ func (m *NinRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field7) == 0 { + m.Field7 = make([]int32, 0, elementCount) + } for iNdEx < postIndex { var v int32 for shift := uint(0); ; shift += 7 { @@ -33431,6 +33573,17 @@ func (m *NinRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field8) == 0 { + m.Field8 = make([]int64, 0, elementCount) + } for iNdEx < postIndex { var v uint64 for shift := uint(0); ; shift += 7 { @@ -33485,8 +33638,10 @@ func (m *NinRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field9) == 0 { - m.Field9 = make([]uint32, 0, packedLen/4) + var elementCount int + elementCount = packedLen / 4 + if elementCount != 0 && len(m.Field9) == 0 { + m.Field9 = make([]uint32, 0, elementCount) } for iNdEx < postIndex { var v uint32 @@ -33532,8 +33687,10 @@ func (m *NinRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field10) == 0 { - m.Field10 = make([]int32, 0, packedLen/4) + var elementCount int + elementCount = packedLen / 4 + if elementCount != 0 && len(m.Field10) == 0 { + m.Field10 = make([]int32, 0, elementCount) } for iNdEx < postIndex { var v int32 @@ -33579,8 +33736,10 @@ func (m *NinRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field11) == 0 { - m.Field11 = make([]uint64, 0, packedLen/8) + var elementCount int + elementCount = packedLen / 8 + if elementCount != 0 && len(m.Field11) == 0 { + m.Field11 = make([]uint64, 0, elementCount) } for iNdEx < postIndex { var v uint64 @@ -33626,8 +33785,10 @@ func (m *NinRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field12) == 0 { - m.Field12 = make([]int64, 0, packedLen/8) + var elementCount int + elementCount = packedLen / 8 + if elementCount != 0 && len(m.Field12) == 0 { + m.Field12 = make([]int64, 0, elementCount) } for iNdEx < postIndex { var v int64 @@ -33682,6 +33843,11 @@ func (m *NinRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + elementCount = packedLen + if elementCount != 0 && len(m.Field13) == 0 { + m.Field13 = make([]bool, 0, elementCount) + } for iNdEx < postIndex { var v int for shift := uint(0); ; shift += 7 { @@ -33845,8 +34011,10 @@ func (m *NidRepPackedNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field1) == 0 { - m.Field1 = make([]float64, 0, packedLen/8) + var elementCount int + elementCount = packedLen / 8 + if elementCount != 0 && len(m.Field1) == 0 { + m.Field1 = make([]float64, 0, elementCount) } for iNdEx < postIndex { var v uint64 @@ -33894,8 +34062,10 @@ func (m *NidRepPackedNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field2) == 0 { - m.Field2 = make([]float32, 0, packedLen/4) + var elementCount int + elementCount = packedLen / 4 + if elementCount != 0 && len(m.Field2) == 0 { + m.Field2 = make([]float32, 0, elementCount) } for iNdEx < postIndex { var v uint32 @@ -33951,6 +34121,17 @@ func (m *NidRepPackedNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field3) == 0 { + m.Field3 = make([]int32, 0, elementCount) + } for iNdEx < postIndex { var v int32 for shift := uint(0); ; shift += 7 { @@ -34013,6 +34194,17 @@ func (m *NidRepPackedNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field4) == 0 { + m.Field4 = make([]int64, 0, elementCount) + } for iNdEx < postIndex { var v int64 for shift := uint(0); ; shift += 7 { @@ -34075,6 +34267,17 @@ func (m *NidRepPackedNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field5) == 0 { + m.Field5 = make([]uint32, 0, elementCount) + } for iNdEx < postIndex { var v uint32 for shift := uint(0); ; shift += 7 { @@ -34137,6 +34340,17 @@ func (m *NidRepPackedNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field6) == 0 { + m.Field6 = make([]uint64, 0, elementCount) + } for iNdEx < postIndex { var v uint64 for shift := uint(0); ; shift += 7 { @@ -34200,6 +34414,17 @@ func (m *NidRepPackedNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field7) == 0 { + m.Field7 = make([]int32, 0, elementCount) + } for iNdEx < postIndex { var v int32 for shift := uint(0); ; shift += 7 { @@ -34264,6 +34489,17 @@ func (m *NidRepPackedNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field8) == 0 { + m.Field8 = make([]int64, 0, elementCount) + } for iNdEx < postIndex { var v uint64 for shift := uint(0); ; shift += 7 { @@ -34318,8 +34554,10 @@ func (m *NidRepPackedNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field9) == 0 { - m.Field9 = make([]uint32, 0, packedLen/4) + var elementCount int + elementCount = packedLen / 4 + if elementCount != 0 && len(m.Field9) == 0 { + m.Field9 = make([]uint32, 0, elementCount) } for iNdEx < postIndex { var v uint32 @@ -34365,8 +34603,10 @@ func (m *NidRepPackedNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field10) == 0 { - m.Field10 = make([]int32, 0, packedLen/4) + var elementCount int + elementCount = packedLen / 4 + if elementCount != 0 && len(m.Field10) == 0 { + m.Field10 = make([]int32, 0, elementCount) } for iNdEx < postIndex { var v int32 @@ -34412,8 +34652,10 @@ func (m *NidRepPackedNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field11) == 0 { - m.Field11 = make([]uint64, 0, packedLen/8) + var elementCount int + elementCount = packedLen / 8 + if elementCount != 0 && len(m.Field11) == 0 { + m.Field11 = make([]uint64, 0, elementCount) } for iNdEx < postIndex { var v uint64 @@ -34459,8 +34701,10 @@ func (m *NidRepPackedNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field12) == 0 { - m.Field12 = make([]int64, 0, packedLen/8) + var elementCount int + elementCount = packedLen / 8 + if elementCount != 0 && len(m.Field12) == 0 { + m.Field12 = make([]int64, 0, elementCount) } for iNdEx < postIndex { var v int64 @@ -34515,6 +34759,11 @@ func (m *NidRepPackedNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + elementCount = packedLen + if elementCount != 0 && len(m.Field13) == 0 { + m.Field13 = make([]bool, 0, elementCount) + } for iNdEx < postIndex { var v int for shift := uint(0); ; shift += 7 { @@ -34620,8 +34869,10 @@ func (m *NinRepPackedNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field1) == 0 { - m.Field1 = make([]float64, 0, packedLen/8) + var elementCount int + elementCount = packedLen / 8 + if elementCount != 0 && len(m.Field1) == 0 { + m.Field1 = make([]float64, 0, elementCount) } for iNdEx < postIndex { var v uint64 @@ -34669,8 +34920,10 @@ func (m *NinRepPackedNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field2) == 0 { - m.Field2 = make([]float32, 0, packedLen/4) + var elementCount int + elementCount = packedLen / 4 + if elementCount != 0 && len(m.Field2) == 0 { + m.Field2 = make([]float32, 0, elementCount) } for iNdEx < postIndex { var v uint32 @@ -34726,6 +34979,17 @@ func (m *NinRepPackedNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field3) == 0 { + m.Field3 = make([]int32, 0, elementCount) + } for iNdEx < postIndex { var v int32 for shift := uint(0); ; shift += 7 { @@ -34788,6 +35052,17 @@ func (m *NinRepPackedNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field4) == 0 { + m.Field4 = make([]int64, 0, elementCount) + } for iNdEx < postIndex { var v int64 for shift := uint(0); ; shift += 7 { @@ -34850,6 +35125,17 @@ func (m *NinRepPackedNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field5) == 0 { + m.Field5 = make([]uint32, 0, elementCount) + } for iNdEx < postIndex { var v uint32 for shift := uint(0); ; shift += 7 { @@ -34912,6 +35198,17 @@ func (m *NinRepPackedNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field6) == 0 { + m.Field6 = make([]uint64, 0, elementCount) + } for iNdEx < postIndex { var v uint64 for shift := uint(0); ; shift += 7 { @@ -34975,6 +35272,17 @@ func (m *NinRepPackedNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field7) == 0 { + m.Field7 = make([]int32, 0, elementCount) + } for iNdEx < postIndex { var v int32 for shift := uint(0); ; shift += 7 { @@ -35039,6 +35347,17 @@ func (m *NinRepPackedNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field8) == 0 { + m.Field8 = make([]int64, 0, elementCount) + } for iNdEx < postIndex { var v uint64 for shift := uint(0); ; shift += 7 { @@ -35093,8 +35412,10 @@ func (m *NinRepPackedNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field9) == 0 { - m.Field9 = make([]uint32, 0, packedLen/4) + var elementCount int + elementCount = packedLen / 4 + if elementCount != 0 && len(m.Field9) == 0 { + m.Field9 = make([]uint32, 0, elementCount) } for iNdEx < postIndex { var v uint32 @@ -35140,8 +35461,10 @@ func (m *NinRepPackedNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field10) == 0 { - m.Field10 = make([]int32, 0, packedLen/4) + var elementCount int + elementCount = packedLen / 4 + if elementCount != 0 && len(m.Field10) == 0 { + m.Field10 = make([]int32, 0, elementCount) } for iNdEx < postIndex { var v int32 @@ -35187,8 +35510,10 @@ func (m *NinRepPackedNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field11) == 0 { - m.Field11 = make([]uint64, 0, packedLen/8) + var elementCount int + elementCount = packedLen / 8 + if elementCount != 0 && len(m.Field11) == 0 { + m.Field11 = make([]uint64, 0, elementCount) } for iNdEx < postIndex { var v uint64 @@ -35234,8 +35559,10 @@ func (m *NinRepPackedNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field12) == 0 { - m.Field12 = make([]int64, 0, packedLen/8) + var elementCount int + elementCount = packedLen / 8 + if elementCount != 0 && len(m.Field12) == 0 { + m.Field12 = make([]int64, 0, elementCount) } for iNdEx < postIndex { var v int64 @@ -35290,6 +35617,11 @@ func (m *NinRepPackedNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + elementCount = packedLen + if elementCount != 0 && len(m.Field13) == 0 { + m.Field13 = make([]bool, 0, elementCount) + } for iNdEx < postIndex { var v int for shift := uint(0); ; shift += 7 { @@ -35975,8 +36307,10 @@ func (m *NidRepStruct) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field1) == 0 { - m.Field1 = make([]float64, 0, packedLen/8) + var elementCount int + elementCount = packedLen / 8 + if elementCount != 0 && len(m.Field1) == 0 { + m.Field1 = make([]float64, 0, elementCount) } for iNdEx < postIndex { var v uint64 @@ -36024,8 +36358,10 @@ func (m *NidRepStruct) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field2) == 0 { - m.Field2 = make([]float32, 0, packedLen/4) + var elementCount int + elementCount = packedLen / 4 + if elementCount != 0 && len(m.Field2) == 0 { + m.Field2 = make([]float32, 0, elementCount) } for iNdEx < postIndex { var v uint32 @@ -36143,6 +36479,17 @@ func (m *NidRepStruct) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field6) == 0 { + m.Field6 = make([]uint64, 0, elementCount) + } for iNdEx < postIndex { var v uint64 for shift := uint(0); ; shift += 7 { @@ -36206,6 +36553,17 @@ func (m *NidRepStruct) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field7) == 0 { + m.Field7 = make([]int32, 0, elementCount) + } for iNdEx < postIndex { var v int32 for shift := uint(0); ; shift += 7 { @@ -36300,6 +36658,11 @@ func (m *NidRepStruct) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + elementCount = packedLen + if elementCount != 0 && len(m.Field13) == 0 { + m.Field13 = make([]bool, 0, elementCount) + } for iNdEx < postIndex { var v int for shift := uint(0); ; shift += 7 { @@ -36463,8 +36826,10 @@ func (m *NinRepStruct) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field1) == 0 { - m.Field1 = make([]float64, 0, packedLen/8) + var elementCount int + elementCount = packedLen / 8 + if elementCount != 0 && len(m.Field1) == 0 { + m.Field1 = make([]float64, 0, elementCount) } for iNdEx < postIndex { var v uint64 @@ -36512,8 +36877,10 @@ func (m *NinRepStruct) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field2) == 0 { - m.Field2 = make([]float32, 0, packedLen/4) + var elementCount int + elementCount = packedLen / 4 + if elementCount != 0 && len(m.Field2) == 0 { + m.Field2 = make([]float32, 0, elementCount) } for iNdEx < postIndex { var v uint32 @@ -36631,6 +36998,17 @@ func (m *NinRepStruct) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field6) == 0 { + m.Field6 = make([]uint64, 0, elementCount) + } for iNdEx < postIndex { var v uint64 for shift := uint(0); ; shift += 7 { @@ -36694,6 +37072,17 @@ func (m *NinRepStruct) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field7) == 0 { + m.Field7 = make([]int32, 0, elementCount) + } for iNdEx < postIndex { var v int32 for shift := uint(0); ; shift += 7 { @@ -36788,6 +37177,11 @@ func (m *NinRepStruct) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + elementCount = packedLen + if elementCount != 0 && len(m.Field13) == 0 { + m.Field13 = make([]bool, 0, elementCount) + } for iNdEx < postIndex { var v int for shift := uint(0); ; shift += 7 { @@ -39912,6 +40306,10 @@ func (m *NidRepEnum) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + if elementCount != 0 && len(m.Field1) == 0 { + m.Field1 = make([]TheTestEnum, 0, elementCount) + } for iNdEx < postIndex { var v TheTestEnum for shift := uint(0); ; shift += 7 { @@ -39974,6 +40372,10 @@ func (m *NidRepEnum) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + if elementCount != 0 && len(m.Field2) == 0 { + m.Field2 = make([]YetAnotherTestEnum, 0, elementCount) + } for iNdEx < postIndex { var v YetAnotherTestEnum for shift := uint(0); ; shift += 7 { @@ -40036,6 +40438,10 @@ func (m *NidRepEnum) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + if elementCount != 0 && len(m.Field3) == 0 { + m.Field3 = make([]YetYetAnotherTestEnum, 0, elementCount) + } for iNdEx < postIndex { var v YetYetAnotherTestEnum for shift := uint(0); ; shift += 7 { @@ -40149,6 +40555,10 @@ func (m *NinRepEnum) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + if elementCount != 0 && len(m.Field1) == 0 { + m.Field1 = make([]TheTestEnum, 0, elementCount) + } for iNdEx < postIndex { var v TheTestEnum for shift := uint(0); ; shift += 7 { @@ -40211,6 +40621,10 @@ func (m *NinRepEnum) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + if elementCount != 0 && len(m.Field2) == 0 { + m.Field2 = make([]YetAnotherTestEnum, 0, elementCount) + } for iNdEx < postIndex { var v YetAnotherTestEnum for shift := uint(0); ; shift += 7 { @@ -40273,6 +40687,10 @@ func (m *NinRepEnum) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + if elementCount != 0 && len(m.Field3) == 0 { + m.Field3 = make([]YetYetAnotherTestEnum, 0, elementCount) + } for iNdEx < postIndex { var v YetYetAnotherTestEnum for shift := uint(0); ; shift += 7 { @@ -42566,8 +42984,10 @@ func (m *CustomNameNinRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.FieldA) == 0 { - m.FieldA = make([]float64, 0, packedLen/8) + var elementCount int + elementCount = packedLen / 8 + if elementCount != 0 && len(m.FieldA) == 0 { + m.FieldA = make([]float64, 0, elementCount) } for iNdEx < postIndex { var v uint64 @@ -42615,8 +43035,10 @@ func (m *CustomNameNinRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.FieldB) == 0 { - m.FieldB = make([]float32, 0, packedLen/4) + var elementCount int + elementCount = packedLen / 4 + if elementCount != 0 && len(m.FieldB) == 0 { + m.FieldB = make([]float32, 0, elementCount) } for iNdEx < postIndex { var v uint32 @@ -42672,6 +43094,17 @@ func (m *CustomNameNinRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.FieldC) == 0 { + m.FieldC = make([]int32, 0, elementCount) + } for iNdEx < postIndex { var v int32 for shift := uint(0); ; shift += 7 { @@ -42734,6 +43167,17 @@ func (m *CustomNameNinRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.FieldD) == 0 { + m.FieldD = make([]int64, 0, elementCount) + } for iNdEx < postIndex { var v int64 for shift := uint(0); ; shift += 7 { @@ -42796,6 +43240,17 @@ func (m *CustomNameNinRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.FieldE) == 0 { + m.FieldE = make([]uint32, 0, elementCount) + } for iNdEx < postIndex { var v uint32 for shift := uint(0); ; shift += 7 { @@ -42858,6 +43313,17 @@ func (m *CustomNameNinRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.FieldF) == 0 { + m.FieldF = make([]uint64, 0, elementCount) + } for iNdEx < postIndex { var v uint64 for shift := uint(0); ; shift += 7 { @@ -42921,6 +43387,17 @@ func (m *CustomNameNinRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.FieldG) == 0 { + m.FieldG = make([]int32, 0, elementCount) + } for iNdEx < postIndex { var v int32 for shift := uint(0); ; shift += 7 { @@ -42985,6 +43462,17 @@ func (m *CustomNameNinRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.FieldH) == 0 { + m.FieldH = make([]int64, 0, elementCount) + } for iNdEx < postIndex { var v uint64 for shift := uint(0); ; shift += 7 { @@ -43039,8 +43527,10 @@ func (m *CustomNameNinRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.FieldI) == 0 { - m.FieldI = make([]uint32, 0, packedLen/4) + var elementCount int + elementCount = packedLen / 4 + if elementCount != 0 && len(m.FieldI) == 0 { + m.FieldI = make([]uint32, 0, elementCount) } for iNdEx < postIndex { var v uint32 @@ -43086,8 +43576,10 @@ func (m *CustomNameNinRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.FieldJ) == 0 { - m.FieldJ = make([]int32, 0, packedLen/4) + var elementCount int + elementCount = packedLen / 4 + if elementCount != 0 && len(m.FieldJ) == 0 { + m.FieldJ = make([]int32, 0, elementCount) } for iNdEx < postIndex { var v int32 @@ -43133,8 +43625,10 @@ func (m *CustomNameNinRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.FieldK) == 0 { - m.FieldK = make([]uint64, 0, packedLen/8) + var elementCount int + elementCount = packedLen / 8 + if elementCount != 0 && len(m.FieldK) == 0 { + m.FieldK = make([]uint64, 0, elementCount) } for iNdEx < postIndex { var v uint64 @@ -43180,8 +43674,10 @@ func (m *CustomNameNinRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.FieldL) == 0 { - m.FieldL = make([]int64, 0, packedLen/8) + var elementCount int + elementCount = packedLen / 8 + if elementCount != 0 && len(m.FieldL) == 0 { + m.FieldL = make([]int64, 0, elementCount) } for iNdEx < postIndex { var v int64 @@ -43236,6 +43732,11 @@ func (m *CustomNameNinRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + elementCount = packedLen + if elementCount != 0 && len(m.FieldM) == 0 { + m.FieldM = make([]bool, 0, elementCount) + } for iNdEx < postIndex { var v int for shift := uint(0); ; shift += 7 { @@ -44039,6 +44540,10 @@ func (m *CustomNameEnum) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + if elementCount != 0 && len(m.FieldB) == 0 { + m.FieldB = make([]TheTestEnum, 0, elementCount) + } for iNdEx < postIndex { var v TheTestEnum for shift := uint(0); ; shift += 7 { diff --git a/test/combos/unmarshaler/thetest.pb.go b/test/combos/unmarshaler/thetest.pb.go index 7238e85701..0a1fee7479 100644 --- a/test/combos/unmarshaler/thetest.pb.go +++ b/test/combos/unmarshaler/thetest.pb.go @@ -27581,8 +27581,10 @@ func (m *NidRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field1) == 0 { - m.Field1 = make([]float64, 0, packedLen/8) + var elementCount int + elementCount = packedLen / 8 + if elementCount != 0 && len(m.Field1) == 0 { + m.Field1 = make([]float64, 0, elementCount) } for iNdEx < postIndex { var v uint64 @@ -27630,8 +27632,10 @@ func (m *NidRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field2) == 0 { - m.Field2 = make([]float32, 0, packedLen/4) + var elementCount int + elementCount = packedLen / 4 + if elementCount != 0 && len(m.Field2) == 0 { + m.Field2 = make([]float32, 0, elementCount) } for iNdEx < postIndex { var v uint32 @@ -27687,6 +27691,17 @@ func (m *NidRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field3) == 0 { + m.Field3 = make([]int32, 0, elementCount) + } for iNdEx < postIndex { var v int32 for shift := uint(0); ; shift += 7 { @@ -27749,6 +27764,17 @@ func (m *NidRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field4) == 0 { + m.Field4 = make([]int64, 0, elementCount) + } for iNdEx < postIndex { var v int64 for shift := uint(0); ; shift += 7 { @@ -27811,6 +27837,17 @@ func (m *NidRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field5) == 0 { + m.Field5 = make([]uint32, 0, elementCount) + } for iNdEx < postIndex { var v uint32 for shift := uint(0); ; shift += 7 { @@ -27873,6 +27910,17 @@ func (m *NidRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field6) == 0 { + m.Field6 = make([]uint64, 0, elementCount) + } for iNdEx < postIndex { var v uint64 for shift := uint(0); ; shift += 7 { @@ -27936,6 +27984,17 @@ func (m *NidRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field7) == 0 { + m.Field7 = make([]int32, 0, elementCount) + } for iNdEx < postIndex { var v int32 for shift := uint(0); ; shift += 7 { @@ -28000,6 +28059,17 @@ func (m *NidRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field8) == 0 { + m.Field8 = make([]int64, 0, elementCount) + } for iNdEx < postIndex { var v uint64 for shift := uint(0); ; shift += 7 { @@ -28054,8 +28124,10 @@ func (m *NidRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field9) == 0 { - m.Field9 = make([]uint32, 0, packedLen/4) + var elementCount int + elementCount = packedLen / 4 + if elementCount != 0 && len(m.Field9) == 0 { + m.Field9 = make([]uint32, 0, elementCount) } for iNdEx < postIndex { var v uint32 @@ -28101,8 +28173,10 @@ func (m *NidRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field10) == 0 { - m.Field10 = make([]int32, 0, packedLen/4) + var elementCount int + elementCount = packedLen / 4 + if elementCount != 0 && len(m.Field10) == 0 { + m.Field10 = make([]int32, 0, elementCount) } for iNdEx < postIndex { var v int32 @@ -28148,8 +28222,10 @@ func (m *NidRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field11) == 0 { - m.Field11 = make([]uint64, 0, packedLen/8) + var elementCount int + elementCount = packedLen / 8 + if elementCount != 0 && len(m.Field11) == 0 { + m.Field11 = make([]uint64, 0, elementCount) } for iNdEx < postIndex { var v uint64 @@ -28195,8 +28271,10 @@ func (m *NidRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field12) == 0 { - m.Field12 = make([]int64, 0, packedLen/8) + var elementCount int + elementCount = packedLen / 8 + if elementCount != 0 && len(m.Field12) == 0 { + m.Field12 = make([]int64, 0, elementCount) } for iNdEx < postIndex { var v int64 @@ -28251,6 +28329,11 @@ func (m *NidRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + elementCount = packedLen + if elementCount != 0 && len(m.Field13) == 0 { + m.Field13 = make([]bool, 0, elementCount) + } for iNdEx < postIndex { var v int for shift := uint(0); ; shift += 7 { @@ -28414,8 +28497,10 @@ func (m *NinRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field1) == 0 { - m.Field1 = make([]float64, 0, packedLen/8) + var elementCount int + elementCount = packedLen / 8 + if elementCount != 0 && len(m.Field1) == 0 { + m.Field1 = make([]float64, 0, elementCount) } for iNdEx < postIndex { var v uint64 @@ -28463,8 +28548,10 @@ func (m *NinRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field2) == 0 { - m.Field2 = make([]float32, 0, packedLen/4) + var elementCount int + elementCount = packedLen / 4 + if elementCount != 0 && len(m.Field2) == 0 { + m.Field2 = make([]float32, 0, elementCount) } for iNdEx < postIndex { var v uint32 @@ -28520,6 +28607,17 @@ func (m *NinRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field3) == 0 { + m.Field3 = make([]int32, 0, elementCount) + } for iNdEx < postIndex { var v int32 for shift := uint(0); ; shift += 7 { @@ -28582,6 +28680,17 @@ func (m *NinRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field4) == 0 { + m.Field4 = make([]int64, 0, elementCount) + } for iNdEx < postIndex { var v int64 for shift := uint(0); ; shift += 7 { @@ -28644,6 +28753,17 @@ func (m *NinRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field5) == 0 { + m.Field5 = make([]uint32, 0, elementCount) + } for iNdEx < postIndex { var v uint32 for shift := uint(0); ; shift += 7 { @@ -28706,6 +28826,17 @@ func (m *NinRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field6) == 0 { + m.Field6 = make([]uint64, 0, elementCount) + } for iNdEx < postIndex { var v uint64 for shift := uint(0); ; shift += 7 { @@ -28769,6 +28900,17 @@ func (m *NinRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field7) == 0 { + m.Field7 = make([]int32, 0, elementCount) + } for iNdEx < postIndex { var v int32 for shift := uint(0); ; shift += 7 { @@ -28833,6 +28975,17 @@ func (m *NinRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field8) == 0 { + m.Field8 = make([]int64, 0, elementCount) + } for iNdEx < postIndex { var v uint64 for shift := uint(0); ; shift += 7 { @@ -28887,8 +29040,10 @@ func (m *NinRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field9) == 0 { - m.Field9 = make([]uint32, 0, packedLen/4) + var elementCount int + elementCount = packedLen / 4 + if elementCount != 0 && len(m.Field9) == 0 { + m.Field9 = make([]uint32, 0, elementCount) } for iNdEx < postIndex { var v uint32 @@ -28934,8 +29089,10 @@ func (m *NinRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field10) == 0 { - m.Field10 = make([]int32, 0, packedLen/4) + var elementCount int + elementCount = packedLen / 4 + if elementCount != 0 && len(m.Field10) == 0 { + m.Field10 = make([]int32, 0, elementCount) } for iNdEx < postIndex { var v int32 @@ -28981,8 +29138,10 @@ func (m *NinRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field11) == 0 { - m.Field11 = make([]uint64, 0, packedLen/8) + var elementCount int + elementCount = packedLen / 8 + if elementCount != 0 && len(m.Field11) == 0 { + m.Field11 = make([]uint64, 0, elementCount) } for iNdEx < postIndex { var v uint64 @@ -29028,8 +29187,10 @@ func (m *NinRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field12) == 0 { - m.Field12 = make([]int64, 0, packedLen/8) + var elementCount int + elementCount = packedLen / 8 + if elementCount != 0 && len(m.Field12) == 0 { + m.Field12 = make([]int64, 0, elementCount) } for iNdEx < postIndex { var v int64 @@ -29084,6 +29245,11 @@ func (m *NinRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + elementCount = packedLen + if elementCount != 0 && len(m.Field13) == 0 { + m.Field13 = make([]bool, 0, elementCount) + } for iNdEx < postIndex { var v int for shift := uint(0); ; shift += 7 { @@ -29247,8 +29413,10 @@ func (m *NidRepPackedNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field1) == 0 { - m.Field1 = make([]float64, 0, packedLen/8) + var elementCount int + elementCount = packedLen / 8 + if elementCount != 0 && len(m.Field1) == 0 { + m.Field1 = make([]float64, 0, elementCount) } for iNdEx < postIndex { var v uint64 @@ -29296,8 +29464,10 @@ func (m *NidRepPackedNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field2) == 0 { - m.Field2 = make([]float32, 0, packedLen/4) + var elementCount int + elementCount = packedLen / 4 + if elementCount != 0 && len(m.Field2) == 0 { + m.Field2 = make([]float32, 0, elementCount) } for iNdEx < postIndex { var v uint32 @@ -29353,6 +29523,17 @@ func (m *NidRepPackedNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field3) == 0 { + m.Field3 = make([]int32, 0, elementCount) + } for iNdEx < postIndex { var v int32 for shift := uint(0); ; shift += 7 { @@ -29415,6 +29596,17 @@ func (m *NidRepPackedNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field4) == 0 { + m.Field4 = make([]int64, 0, elementCount) + } for iNdEx < postIndex { var v int64 for shift := uint(0); ; shift += 7 { @@ -29477,6 +29669,17 @@ func (m *NidRepPackedNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field5) == 0 { + m.Field5 = make([]uint32, 0, elementCount) + } for iNdEx < postIndex { var v uint32 for shift := uint(0); ; shift += 7 { @@ -29539,6 +29742,17 @@ func (m *NidRepPackedNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field6) == 0 { + m.Field6 = make([]uint64, 0, elementCount) + } for iNdEx < postIndex { var v uint64 for shift := uint(0); ; shift += 7 { @@ -29602,6 +29816,17 @@ func (m *NidRepPackedNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field7) == 0 { + m.Field7 = make([]int32, 0, elementCount) + } for iNdEx < postIndex { var v int32 for shift := uint(0); ; shift += 7 { @@ -29666,6 +29891,17 @@ func (m *NidRepPackedNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field8) == 0 { + m.Field8 = make([]int64, 0, elementCount) + } for iNdEx < postIndex { var v uint64 for shift := uint(0); ; shift += 7 { @@ -29720,8 +29956,10 @@ func (m *NidRepPackedNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field9) == 0 { - m.Field9 = make([]uint32, 0, packedLen/4) + var elementCount int + elementCount = packedLen / 4 + if elementCount != 0 && len(m.Field9) == 0 { + m.Field9 = make([]uint32, 0, elementCount) } for iNdEx < postIndex { var v uint32 @@ -29767,8 +30005,10 @@ func (m *NidRepPackedNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field10) == 0 { - m.Field10 = make([]int32, 0, packedLen/4) + var elementCount int + elementCount = packedLen / 4 + if elementCount != 0 && len(m.Field10) == 0 { + m.Field10 = make([]int32, 0, elementCount) } for iNdEx < postIndex { var v int32 @@ -29814,8 +30054,10 @@ func (m *NidRepPackedNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field11) == 0 { - m.Field11 = make([]uint64, 0, packedLen/8) + var elementCount int + elementCount = packedLen / 8 + if elementCount != 0 && len(m.Field11) == 0 { + m.Field11 = make([]uint64, 0, elementCount) } for iNdEx < postIndex { var v uint64 @@ -29861,8 +30103,10 @@ func (m *NidRepPackedNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field12) == 0 { - m.Field12 = make([]int64, 0, packedLen/8) + var elementCount int + elementCount = packedLen / 8 + if elementCount != 0 && len(m.Field12) == 0 { + m.Field12 = make([]int64, 0, elementCount) } for iNdEx < postIndex { var v int64 @@ -29917,6 +30161,11 @@ func (m *NidRepPackedNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + elementCount = packedLen + if elementCount != 0 && len(m.Field13) == 0 { + m.Field13 = make([]bool, 0, elementCount) + } for iNdEx < postIndex { var v int for shift := uint(0); ; shift += 7 { @@ -30022,8 +30271,10 @@ func (m *NinRepPackedNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field1) == 0 { - m.Field1 = make([]float64, 0, packedLen/8) + var elementCount int + elementCount = packedLen / 8 + if elementCount != 0 && len(m.Field1) == 0 { + m.Field1 = make([]float64, 0, elementCount) } for iNdEx < postIndex { var v uint64 @@ -30071,8 +30322,10 @@ func (m *NinRepPackedNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field2) == 0 { - m.Field2 = make([]float32, 0, packedLen/4) + var elementCount int + elementCount = packedLen / 4 + if elementCount != 0 && len(m.Field2) == 0 { + m.Field2 = make([]float32, 0, elementCount) } for iNdEx < postIndex { var v uint32 @@ -30128,6 +30381,17 @@ func (m *NinRepPackedNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field3) == 0 { + m.Field3 = make([]int32, 0, elementCount) + } for iNdEx < postIndex { var v int32 for shift := uint(0); ; shift += 7 { @@ -30190,6 +30454,17 @@ func (m *NinRepPackedNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field4) == 0 { + m.Field4 = make([]int64, 0, elementCount) + } for iNdEx < postIndex { var v int64 for shift := uint(0); ; shift += 7 { @@ -30252,6 +30527,17 @@ func (m *NinRepPackedNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field5) == 0 { + m.Field5 = make([]uint32, 0, elementCount) + } for iNdEx < postIndex { var v uint32 for shift := uint(0); ; shift += 7 { @@ -30314,6 +30600,17 @@ func (m *NinRepPackedNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field6) == 0 { + m.Field6 = make([]uint64, 0, elementCount) + } for iNdEx < postIndex { var v uint64 for shift := uint(0); ; shift += 7 { @@ -30377,6 +30674,17 @@ func (m *NinRepPackedNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field7) == 0 { + m.Field7 = make([]int32, 0, elementCount) + } for iNdEx < postIndex { var v int32 for shift := uint(0); ; shift += 7 { @@ -30441,6 +30749,17 @@ func (m *NinRepPackedNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field8) == 0 { + m.Field8 = make([]int64, 0, elementCount) + } for iNdEx < postIndex { var v uint64 for shift := uint(0); ; shift += 7 { @@ -30495,8 +30814,10 @@ func (m *NinRepPackedNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field9) == 0 { - m.Field9 = make([]uint32, 0, packedLen/4) + var elementCount int + elementCount = packedLen / 4 + if elementCount != 0 && len(m.Field9) == 0 { + m.Field9 = make([]uint32, 0, elementCount) } for iNdEx < postIndex { var v uint32 @@ -30542,8 +30863,10 @@ func (m *NinRepPackedNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field10) == 0 { - m.Field10 = make([]int32, 0, packedLen/4) + var elementCount int + elementCount = packedLen / 4 + if elementCount != 0 && len(m.Field10) == 0 { + m.Field10 = make([]int32, 0, elementCount) } for iNdEx < postIndex { var v int32 @@ -30589,8 +30912,10 @@ func (m *NinRepPackedNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field11) == 0 { - m.Field11 = make([]uint64, 0, packedLen/8) + var elementCount int + elementCount = packedLen / 8 + if elementCount != 0 && len(m.Field11) == 0 { + m.Field11 = make([]uint64, 0, elementCount) } for iNdEx < postIndex { var v uint64 @@ -30636,8 +30961,10 @@ func (m *NinRepPackedNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field12) == 0 { - m.Field12 = make([]int64, 0, packedLen/8) + var elementCount int + elementCount = packedLen / 8 + if elementCount != 0 && len(m.Field12) == 0 { + m.Field12 = make([]int64, 0, elementCount) } for iNdEx < postIndex { var v int64 @@ -30692,6 +31019,11 @@ func (m *NinRepPackedNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + elementCount = packedLen + if elementCount != 0 && len(m.Field13) == 0 { + m.Field13 = make([]bool, 0, elementCount) + } for iNdEx < postIndex { var v int for shift := uint(0); ; shift += 7 { @@ -31377,8 +31709,10 @@ func (m *NidRepStruct) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field1) == 0 { - m.Field1 = make([]float64, 0, packedLen/8) + var elementCount int + elementCount = packedLen / 8 + if elementCount != 0 && len(m.Field1) == 0 { + m.Field1 = make([]float64, 0, elementCount) } for iNdEx < postIndex { var v uint64 @@ -31426,8 +31760,10 @@ func (m *NidRepStruct) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field2) == 0 { - m.Field2 = make([]float32, 0, packedLen/4) + var elementCount int + elementCount = packedLen / 4 + if elementCount != 0 && len(m.Field2) == 0 { + m.Field2 = make([]float32, 0, elementCount) } for iNdEx < postIndex { var v uint32 @@ -31545,6 +31881,17 @@ func (m *NidRepStruct) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field6) == 0 { + m.Field6 = make([]uint64, 0, elementCount) + } for iNdEx < postIndex { var v uint64 for shift := uint(0); ; shift += 7 { @@ -31608,6 +31955,17 @@ func (m *NidRepStruct) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field7) == 0 { + m.Field7 = make([]int32, 0, elementCount) + } for iNdEx < postIndex { var v int32 for shift := uint(0); ; shift += 7 { @@ -31702,6 +32060,11 @@ func (m *NidRepStruct) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + elementCount = packedLen + if elementCount != 0 && len(m.Field13) == 0 { + m.Field13 = make([]bool, 0, elementCount) + } for iNdEx < postIndex { var v int for shift := uint(0); ; shift += 7 { @@ -31865,8 +32228,10 @@ func (m *NinRepStruct) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field1) == 0 { - m.Field1 = make([]float64, 0, packedLen/8) + var elementCount int + elementCount = packedLen / 8 + if elementCount != 0 && len(m.Field1) == 0 { + m.Field1 = make([]float64, 0, elementCount) } for iNdEx < postIndex { var v uint64 @@ -31914,8 +32279,10 @@ func (m *NinRepStruct) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field2) == 0 { - m.Field2 = make([]float32, 0, packedLen/4) + var elementCount int + elementCount = packedLen / 4 + if elementCount != 0 && len(m.Field2) == 0 { + m.Field2 = make([]float32, 0, elementCount) } for iNdEx < postIndex { var v uint32 @@ -32033,6 +32400,17 @@ func (m *NinRepStruct) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field6) == 0 { + m.Field6 = make([]uint64, 0, elementCount) + } for iNdEx < postIndex { var v uint64 for shift := uint(0); ; shift += 7 { @@ -32096,6 +32474,17 @@ func (m *NinRepStruct) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field7) == 0 { + m.Field7 = make([]int32, 0, elementCount) + } for iNdEx < postIndex { var v int32 for shift := uint(0); ; shift += 7 { @@ -32190,6 +32579,11 @@ func (m *NinRepStruct) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + elementCount = packedLen + if elementCount != 0 && len(m.Field13) == 0 { + m.Field13 = make([]bool, 0, elementCount) + } for iNdEx < postIndex { var v int for shift := uint(0); ; shift += 7 { @@ -35314,6 +35708,10 @@ func (m *NidRepEnum) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + if elementCount != 0 && len(m.Field1) == 0 { + m.Field1 = make([]TheTestEnum, 0, elementCount) + } for iNdEx < postIndex { var v TheTestEnum for shift := uint(0); ; shift += 7 { @@ -35376,6 +35774,10 @@ func (m *NidRepEnum) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + if elementCount != 0 && len(m.Field2) == 0 { + m.Field2 = make([]YetAnotherTestEnum, 0, elementCount) + } for iNdEx < postIndex { var v YetAnotherTestEnum for shift := uint(0); ; shift += 7 { @@ -35438,6 +35840,10 @@ func (m *NidRepEnum) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + if elementCount != 0 && len(m.Field3) == 0 { + m.Field3 = make([]YetYetAnotherTestEnum, 0, elementCount) + } for iNdEx < postIndex { var v YetYetAnotherTestEnum for shift := uint(0); ; shift += 7 { @@ -35551,6 +35957,10 @@ func (m *NinRepEnum) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + if elementCount != 0 && len(m.Field1) == 0 { + m.Field1 = make([]TheTestEnum, 0, elementCount) + } for iNdEx < postIndex { var v TheTestEnum for shift := uint(0); ; shift += 7 { @@ -35613,6 +36023,10 @@ func (m *NinRepEnum) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + if elementCount != 0 && len(m.Field2) == 0 { + m.Field2 = make([]YetAnotherTestEnum, 0, elementCount) + } for iNdEx < postIndex { var v YetAnotherTestEnum for shift := uint(0); ; shift += 7 { @@ -35675,6 +36089,10 @@ func (m *NinRepEnum) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + if elementCount != 0 && len(m.Field3) == 0 { + m.Field3 = make([]YetYetAnotherTestEnum, 0, elementCount) + } for iNdEx < postIndex { var v YetYetAnotherTestEnum for shift := uint(0); ; shift += 7 { @@ -37968,8 +38386,10 @@ func (m *CustomNameNinRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.FieldA) == 0 { - m.FieldA = make([]float64, 0, packedLen/8) + var elementCount int + elementCount = packedLen / 8 + if elementCount != 0 && len(m.FieldA) == 0 { + m.FieldA = make([]float64, 0, elementCount) } for iNdEx < postIndex { var v uint64 @@ -38017,8 +38437,10 @@ func (m *CustomNameNinRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.FieldB) == 0 { - m.FieldB = make([]float32, 0, packedLen/4) + var elementCount int + elementCount = packedLen / 4 + if elementCount != 0 && len(m.FieldB) == 0 { + m.FieldB = make([]float32, 0, elementCount) } for iNdEx < postIndex { var v uint32 @@ -38074,6 +38496,17 @@ func (m *CustomNameNinRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.FieldC) == 0 { + m.FieldC = make([]int32, 0, elementCount) + } for iNdEx < postIndex { var v int32 for shift := uint(0); ; shift += 7 { @@ -38136,6 +38569,17 @@ func (m *CustomNameNinRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.FieldD) == 0 { + m.FieldD = make([]int64, 0, elementCount) + } for iNdEx < postIndex { var v int64 for shift := uint(0); ; shift += 7 { @@ -38198,6 +38642,17 @@ func (m *CustomNameNinRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.FieldE) == 0 { + m.FieldE = make([]uint32, 0, elementCount) + } for iNdEx < postIndex { var v uint32 for shift := uint(0); ; shift += 7 { @@ -38260,6 +38715,17 @@ func (m *CustomNameNinRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.FieldF) == 0 { + m.FieldF = make([]uint64, 0, elementCount) + } for iNdEx < postIndex { var v uint64 for shift := uint(0); ; shift += 7 { @@ -38323,6 +38789,17 @@ func (m *CustomNameNinRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.FieldG) == 0 { + m.FieldG = make([]int32, 0, elementCount) + } for iNdEx < postIndex { var v int32 for shift := uint(0); ; shift += 7 { @@ -38387,6 +38864,17 @@ func (m *CustomNameNinRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.FieldH) == 0 { + m.FieldH = make([]int64, 0, elementCount) + } for iNdEx < postIndex { var v uint64 for shift := uint(0); ; shift += 7 { @@ -38441,8 +38929,10 @@ func (m *CustomNameNinRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.FieldI) == 0 { - m.FieldI = make([]uint32, 0, packedLen/4) + var elementCount int + elementCount = packedLen / 4 + if elementCount != 0 && len(m.FieldI) == 0 { + m.FieldI = make([]uint32, 0, elementCount) } for iNdEx < postIndex { var v uint32 @@ -38488,8 +38978,10 @@ func (m *CustomNameNinRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.FieldJ) == 0 { - m.FieldJ = make([]int32, 0, packedLen/4) + var elementCount int + elementCount = packedLen / 4 + if elementCount != 0 && len(m.FieldJ) == 0 { + m.FieldJ = make([]int32, 0, elementCount) } for iNdEx < postIndex { var v int32 @@ -38535,8 +39027,10 @@ func (m *CustomNameNinRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.FieldK) == 0 { - m.FieldK = make([]uint64, 0, packedLen/8) + var elementCount int + elementCount = packedLen / 8 + if elementCount != 0 && len(m.FieldK) == 0 { + m.FieldK = make([]uint64, 0, elementCount) } for iNdEx < postIndex { var v uint64 @@ -38582,8 +39076,10 @@ func (m *CustomNameNinRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.FieldL) == 0 { - m.FieldL = make([]int64, 0, packedLen/8) + var elementCount int + elementCount = packedLen / 8 + if elementCount != 0 && len(m.FieldL) == 0 { + m.FieldL = make([]int64, 0, elementCount) } for iNdEx < postIndex { var v int64 @@ -38638,6 +39134,11 @@ func (m *CustomNameNinRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + elementCount = packedLen + if elementCount != 0 && len(m.FieldM) == 0 { + m.FieldM = make([]bool, 0, elementCount) + } for iNdEx < postIndex { var v int for shift := uint(0); ; shift += 7 { @@ -39441,6 +39942,10 @@ func (m *CustomNameEnum) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + if elementCount != 0 && len(m.FieldB) == 0 { + m.FieldB = make([]TheTestEnum, 0, elementCount) + } for iNdEx < postIndex { var v TheTestEnum for shift := uint(0); ; shift += 7 { diff --git a/test/fuzztests/fuzz.pb.go b/test/fuzztests/fuzz.pb.go index 3102b724a4..0c5c0baf36 100644 --- a/test/fuzztests/fuzz.pb.go +++ b/test/fuzztests/fuzz.pb.go @@ -1411,8 +1411,10 @@ func (m *NinRepPackedNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field1) == 0 { - m.Field1 = make([]float64, 0, packedLen/8) + var elementCount int + elementCount = packedLen / 8 + if elementCount != 0 && len(m.Field1) == 0 { + m.Field1 = make([]float64, 0, elementCount) } for iNdEx < postIndex { var v uint64 @@ -1460,8 +1462,10 @@ func (m *NinRepPackedNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field2) == 0 { - m.Field2 = make([]float32, 0, packedLen/4) + var elementCount int + elementCount = packedLen / 4 + if elementCount != 0 && len(m.Field2) == 0 { + m.Field2 = make([]float32, 0, elementCount) } for iNdEx < postIndex { var v uint32 @@ -1517,6 +1521,17 @@ func (m *NinRepPackedNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field3) == 0 { + m.Field3 = make([]int32, 0, elementCount) + } for iNdEx < postIndex { var v int32 for shift := uint(0); ; shift += 7 { @@ -1579,6 +1594,17 @@ func (m *NinRepPackedNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field4) == 0 { + m.Field4 = make([]int64, 0, elementCount) + } for iNdEx < postIndex { var v int64 for shift := uint(0); ; shift += 7 { @@ -1641,6 +1667,17 @@ func (m *NinRepPackedNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field5) == 0 { + m.Field5 = make([]uint32, 0, elementCount) + } for iNdEx < postIndex { var v uint32 for shift := uint(0); ; shift += 7 { @@ -1703,6 +1740,17 @@ func (m *NinRepPackedNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field6) == 0 { + m.Field6 = make([]uint64, 0, elementCount) + } for iNdEx < postIndex { var v uint64 for shift := uint(0); ; shift += 7 { @@ -1766,6 +1814,17 @@ func (m *NinRepPackedNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field7) == 0 { + m.Field7 = make([]int32, 0, elementCount) + } for iNdEx < postIndex { var v int32 for shift := uint(0); ; shift += 7 { @@ -1830,6 +1889,17 @@ func (m *NinRepPackedNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field8) == 0 { + m.Field8 = make([]int64, 0, elementCount) + } for iNdEx < postIndex { var v uint64 for shift := uint(0); ; shift += 7 { @@ -1884,8 +1954,10 @@ func (m *NinRepPackedNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field9) == 0 { - m.Field9 = make([]uint32, 0, packedLen/4) + var elementCount int + elementCount = packedLen / 4 + if elementCount != 0 && len(m.Field9) == 0 { + m.Field9 = make([]uint32, 0, elementCount) } for iNdEx < postIndex { var v uint32 @@ -1931,8 +2003,10 @@ func (m *NinRepPackedNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field10) == 0 { - m.Field10 = make([]int32, 0, packedLen/4) + var elementCount int + elementCount = packedLen / 4 + if elementCount != 0 && len(m.Field10) == 0 { + m.Field10 = make([]int32, 0, elementCount) } for iNdEx < postIndex { var v int32 @@ -1978,8 +2052,10 @@ func (m *NinRepPackedNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field11) == 0 { - m.Field11 = make([]uint64, 0, packedLen/8) + var elementCount int + elementCount = packedLen / 8 + if elementCount != 0 && len(m.Field11) == 0 { + m.Field11 = make([]uint64, 0, elementCount) } for iNdEx < postIndex { var v uint64 @@ -2025,8 +2101,10 @@ func (m *NinRepPackedNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field12) == 0 { - m.Field12 = make([]int64, 0, packedLen/8) + var elementCount int + elementCount = packedLen / 8 + if elementCount != 0 && len(m.Field12) == 0 { + m.Field12 = make([]int64, 0, elementCount) } for iNdEx < postIndex { var v int64 @@ -2081,6 +2159,11 @@ func (m *NinRepPackedNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + elementCount = packedLen + if elementCount != 0 && len(m.Field13) == 0 { + m.Field13 = make([]bool, 0, elementCount) + } for iNdEx < postIndex { var v int for shift := uint(0); ; shift += 7 { diff --git a/test/packed/packed.pb.go b/test/packed/packed.pb.go index 32020b12fc..5db9510009 100644 --- a/test/packed/packed.pb.go +++ b/test/packed/packed.pb.go @@ -1190,8 +1190,10 @@ func (m *NinRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field1) == 0 { - m.Field1 = make([]float64, 0, packedLen/8) + var elementCount int + elementCount = packedLen / 8 + if elementCount != 0 && len(m.Field1) == 0 { + m.Field1 = make([]float64, 0, elementCount) } for iNdEx < postIndex { var v uint64 @@ -1239,8 +1241,10 @@ func (m *NinRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field2) == 0 { - m.Field2 = make([]float32, 0, packedLen/4) + var elementCount int + elementCount = packedLen / 4 + if elementCount != 0 && len(m.Field2) == 0 { + m.Field2 = make([]float32, 0, elementCount) } for iNdEx < postIndex { var v uint32 @@ -1296,6 +1300,17 @@ func (m *NinRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field3) == 0 { + m.Field3 = make([]int32, 0, elementCount) + } for iNdEx < postIndex { var v int32 for shift := uint(0); ; shift += 7 { @@ -1358,6 +1373,17 @@ func (m *NinRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field4) == 0 { + m.Field4 = make([]int64, 0, elementCount) + } for iNdEx < postIndex { var v int64 for shift := uint(0); ; shift += 7 { @@ -1420,6 +1446,17 @@ func (m *NinRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field5) == 0 { + m.Field5 = make([]uint32, 0, elementCount) + } for iNdEx < postIndex { var v uint32 for shift := uint(0); ; shift += 7 { @@ -1482,6 +1519,17 @@ func (m *NinRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field6) == 0 { + m.Field6 = make([]uint64, 0, elementCount) + } for iNdEx < postIndex { var v uint64 for shift := uint(0); ; shift += 7 { @@ -1545,6 +1593,17 @@ func (m *NinRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field7) == 0 { + m.Field7 = make([]int32, 0, elementCount) + } for iNdEx < postIndex { var v int32 for shift := uint(0); ; shift += 7 { @@ -1609,6 +1668,17 @@ func (m *NinRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field8) == 0 { + m.Field8 = make([]int64, 0, elementCount) + } for iNdEx < postIndex { var v uint64 for shift := uint(0); ; shift += 7 { @@ -1663,8 +1733,10 @@ func (m *NinRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field9) == 0 { - m.Field9 = make([]uint32, 0, packedLen/4) + var elementCount int + elementCount = packedLen / 4 + if elementCount != 0 && len(m.Field9) == 0 { + m.Field9 = make([]uint32, 0, elementCount) } for iNdEx < postIndex { var v uint32 @@ -1710,8 +1782,10 @@ func (m *NinRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field10) == 0 { - m.Field10 = make([]int32, 0, packedLen/4) + var elementCount int + elementCount = packedLen / 4 + if elementCount != 0 && len(m.Field10) == 0 { + m.Field10 = make([]int32, 0, elementCount) } for iNdEx < postIndex { var v int32 @@ -1757,8 +1831,10 @@ func (m *NinRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field11) == 0 { - m.Field11 = make([]uint64, 0, packedLen/8) + var elementCount int + elementCount = packedLen / 8 + if elementCount != 0 && len(m.Field11) == 0 { + m.Field11 = make([]uint64, 0, elementCount) } for iNdEx < postIndex { var v uint64 @@ -1804,8 +1880,10 @@ func (m *NinRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field12) == 0 { - m.Field12 = make([]int64, 0, packedLen/8) + var elementCount int + elementCount = packedLen / 8 + if elementCount != 0 && len(m.Field12) == 0 { + m.Field12 = make([]int64, 0, elementCount) } for iNdEx < postIndex { var v int64 @@ -1860,6 +1938,11 @@ func (m *NinRepNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + elementCount = packedLen + if elementCount != 0 && len(m.Field13) == 0 { + m.Field13 = make([]bool, 0, elementCount) + } for iNdEx < postIndex { var v int for shift := uint(0); ; shift += 7 { @@ -1965,8 +2048,10 @@ func (m *NinRepPackedNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field1) == 0 { - m.Field1 = make([]float64, 0, packedLen/8) + var elementCount int + elementCount = packedLen / 8 + if elementCount != 0 && len(m.Field1) == 0 { + m.Field1 = make([]float64, 0, elementCount) } for iNdEx < postIndex { var v uint64 @@ -2014,8 +2099,10 @@ func (m *NinRepPackedNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field2) == 0 { - m.Field2 = make([]float32, 0, packedLen/4) + var elementCount int + elementCount = packedLen / 4 + if elementCount != 0 && len(m.Field2) == 0 { + m.Field2 = make([]float32, 0, elementCount) } for iNdEx < postIndex { var v uint32 @@ -2071,6 +2158,17 @@ func (m *NinRepPackedNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field3) == 0 { + m.Field3 = make([]int32, 0, elementCount) + } for iNdEx < postIndex { var v int32 for shift := uint(0); ; shift += 7 { @@ -2133,6 +2231,17 @@ func (m *NinRepPackedNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field4) == 0 { + m.Field4 = make([]int64, 0, elementCount) + } for iNdEx < postIndex { var v int64 for shift := uint(0); ; shift += 7 { @@ -2195,6 +2304,17 @@ func (m *NinRepPackedNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field5) == 0 { + m.Field5 = make([]uint32, 0, elementCount) + } for iNdEx < postIndex { var v uint32 for shift := uint(0); ; shift += 7 { @@ -2257,6 +2377,17 @@ func (m *NinRepPackedNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field6) == 0 { + m.Field6 = make([]uint64, 0, elementCount) + } for iNdEx < postIndex { var v uint64 for shift := uint(0); ; shift += 7 { @@ -2320,6 +2451,17 @@ func (m *NinRepPackedNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field7) == 0 { + m.Field7 = make([]int32, 0, elementCount) + } for iNdEx < postIndex { var v int32 for shift := uint(0); ; shift += 7 { @@ -2384,6 +2526,17 @@ func (m *NinRepPackedNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field8) == 0 { + m.Field8 = make([]int64, 0, elementCount) + } for iNdEx < postIndex { var v uint64 for shift := uint(0); ; shift += 7 { @@ -2438,8 +2591,10 @@ func (m *NinRepPackedNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field9) == 0 { - m.Field9 = make([]uint32, 0, packedLen/4) + var elementCount int + elementCount = packedLen / 4 + if elementCount != 0 && len(m.Field9) == 0 { + m.Field9 = make([]uint32, 0, elementCount) } for iNdEx < postIndex { var v uint32 @@ -2485,8 +2640,10 @@ func (m *NinRepPackedNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field10) == 0 { - m.Field10 = make([]int32, 0, packedLen/4) + var elementCount int + elementCount = packedLen / 4 + if elementCount != 0 && len(m.Field10) == 0 { + m.Field10 = make([]int32, 0, elementCount) } for iNdEx < postIndex { var v int32 @@ -2532,8 +2689,10 @@ func (m *NinRepPackedNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field11) == 0 { - m.Field11 = make([]uint64, 0, packedLen/8) + var elementCount int + elementCount = packedLen / 8 + if elementCount != 0 && len(m.Field11) == 0 { + m.Field11 = make([]uint64, 0, elementCount) } for iNdEx < postIndex { var v uint64 @@ -2579,8 +2738,10 @@ func (m *NinRepPackedNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field12) == 0 { - m.Field12 = make([]int64, 0, packedLen/8) + var elementCount int + elementCount = packedLen / 8 + if elementCount != 0 && len(m.Field12) == 0 { + m.Field12 = make([]int64, 0, elementCount) } for iNdEx < postIndex { var v int64 @@ -2635,6 +2796,11 @@ func (m *NinRepPackedNative) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + elementCount = packedLen + if elementCount != 0 && len(m.Field13) == 0 { + m.Field13 = make([]bool, 0, elementCount) + } for iNdEx < postIndex { var v int for shift := uint(0); ; shift += 7 { @@ -2740,8 +2906,10 @@ func (m *NinRepNativeUnsafe) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field1) == 0 { - m.Field1 = make([]float64, 0, packedLen/8) + var elementCount int + elementCount = packedLen / 8 + if elementCount != 0 && len(m.Field1) == 0 { + m.Field1 = make([]float64, 0, elementCount) } for iNdEx < postIndex { var v uint64 @@ -2789,8 +2957,10 @@ func (m *NinRepNativeUnsafe) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field2) == 0 { - m.Field2 = make([]float32, 0, packedLen/4) + var elementCount int + elementCount = packedLen / 4 + if elementCount != 0 && len(m.Field2) == 0 { + m.Field2 = make([]float32, 0, elementCount) } for iNdEx < postIndex { var v uint32 @@ -2846,6 +3016,17 @@ func (m *NinRepNativeUnsafe) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field3) == 0 { + m.Field3 = make([]int32, 0, elementCount) + } for iNdEx < postIndex { var v int32 for shift := uint(0); ; shift += 7 { @@ -2908,6 +3089,17 @@ func (m *NinRepNativeUnsafe) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field4) == 0 { + m.Field4 = make([]int64, 0, elementCount) + } for iNdEx < postIndex { var v int64 for shift := uint(0); ; shift += 7 { @@ -2970,6 +3162,17 @@ func (m *NinRepNativeUnsafe) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field5) == 0 { + m.Field5 = make([]uint32, 0, elementCount) + } for iNdEx < postIndex { var v uint32 for shift := uint(0); ; shift += 7 { @@ -3032,6 +3235,17 @@ func (m *NinRepNativeUnsafe) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field6) == 0 { + m.Field6 = make([]uint64, 0, elementCount) + } for iNdEx < postIndex { var v uint64 for shift := uint(0); ; shift += 7 { @@ -3095,6 +3309,17 @@ func (m *NinRepNativeUnsafe) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field7) == 0 { + m.Field7 = make([]int32, 0, elementCount) + } for iNdEx < postIndex { var v int32 for shift := uint(0); ; shift += 7 { @@ -3159,6 +3384,17 @@ func (m *NinRepNativeUnsafe) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field8) == 0 { + m.Field8 = make([]int64, 0, elementCount) + } for iNdEx < postIndex { var v uint64 for shift := uint(0); ; shift += 7 { @@ -3213,8 +3449,10 @@ func (m *NinRepNativeUnsafe) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field9) == 0 { - m.Field9 = make([]uint32, 0, packedLen/4) + var elementCount int + elementCount = packedLen / 4 + if elementCount != 0 && len(m.Field9) == 0 { + m.Field9 = make([]uint32, 0, elementCount) } for iNdEx < postIndex { var v uint32 @@ -3260,8 +3498,10 @@ func (m *NinRepNativeUnsafe) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field10) == 0 { - m.Field10 = make([]int32, 0, packedLen/4) + var elementCount int + elementCount = packedLen / 4 + if elementCount != 0 && len(m.Field10) == 0 { + m.Field10 = make([]int32, 0, elementCount) } for iNdEx < postIndex { var v int32 @@ -3307,8 +3547,10 @@ func (m *NinRepNativeUnsafe) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field11) == 0 { - m.Field11 = make([]uint64, 0, packedLen/8) + var elementCount int + elementCount = packedLen / 8 + if elementCount != 0 && len(m.Field11) == 0 { + m.Field11 = make([]uint64, 0, elementCount) } for iNdEx < postIndex { var v uint64 @@ -3354,8 +3596,10 @@ func (m *NinRepNativeUnsafe) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field12) == 0 { - m.Field12 = make([]int64, 0, packedLen/8) + var elementCount int + elementCount = packedLen / 8 + if elementCount != 0 && len(m.Field12) == 0 { + m.Field12 = make([]int64, 0, elementCount) } for iNdEx < postIndex { var v int64 @@ -3410,6 +3654,11 @@ func (m *NinRepNativeUnsafe) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + elementCount = packedLen + if elementCount != 0 && len(m.Field13) == 0 { + m.Field13 = make([]bool, 0, elementCount) + } for iNdEx < postIndex { var v int for shift := uint(0); ; shift += 7 { @@ -3515,8 +3764,10 @@ func (m *NinRepPackedNativeUnsafe) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field1) == 0 { - m.Field1 = make([]float64, 0, packedLen/8) + var elementCount int + elementCount = packedLen / 8 + if elementCount != 0 && len(m.Field1) == 0 { + m.Field1 = make([]float64, 0, elementCount) } for iNdEx < postIndex { var v uint64 @@ -3564,8 +3815,10 @@ func (m *NinRepPackedNativeUnsafe) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field2) == 0 { - m.Field2 = make([]float32, 0, packedLen/4) + var elementCount int + elementCount = packedLen / 4 + if elementCount != 0 && len(m.Field2) == 0 { + m.Field2 = make([]float32, 0, elementCount) } for iNdEx < postIndex { var v uint32 @@ -3621,6 +3874,17 @@ func (m *NinRepPackedNativeUnsafe) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field3) == 0 { + m.Field3 = make([]int32, 0, elementCount) + } for iNdEx < postIndex { var v int32 for shift := uint(0); ; shift += 7 { @@ -3683,6 +3947,17 @@ func (m *NinRepPackedNativeUnsafe) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field4) == 0 { + m.Field4 = make([]int64, 0, elementCount) + } for iNdEx < postIndex { var v int64 for shift := uint(0); ; shift += 7 { @@ -3745,6 +4020,17 @@ func (m *NinRepPackedNativeUnsafe) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field5) == 0 { + m.Field5 = make([]uint32, 0, elementCount) + } for iNdEx < postIndex { var v uint32 for shift := uint(0); ; shift += 7 { @@ -3807,6 +4093,17 @@ func (m *NinRepPackedNativeUnsafe) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field6) == 0 { + m.Field6 = make([]uint64, 0, elementCount) + } for iNdEx < postIndex { var v uint64 for shift := uint(0); ; shift += 7 { @@ -3870,6 +4167,17 @@ func (m *NinRepPackedNativeUnsafe) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field7) == 0 { + m.Field7 = make([]int32, 0, elementCount) + } for iNdEx < postIndex { var v int32 for shift := uint(0); ; shift += 7 { @@ -3934,6 +4242,17 @@ func (m *NinRepPackedNativeUnsafe) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Field8) == 0 { + m.Field8 = make([]int64, 0, elementCount) + } for iNdEx < postIndex { var v uint64 for shift := uint(0); ; shift += 7 { @@ -3988,8 +4307,10 @@ func (m *NinRepPackedNativeUnsafe) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field9) == 0 { - m.Field9 = make([]uint32, 0, packedLen/4) + var elementCount int + elementCount = packedLen / 4 + if elementCount != 0 && len(m.Field9) == 0 { + m.Field9 = make([]uint32, 0, elementCount) } for iNdEx < postIndex { var v uint32 @@ -4035,8 +4356,10 @@ func (m *NinRepPackedNativeUnsafe) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field10) == 0 { - m.Field10 = make([]int32, 0, packedLen/4) + var elementCount int + elementCount = packedLen / 4 + if elementCount != 0 && len(m.Field10) == 0 { + m.Field10 = make([]int32, 0, elementCount) } for iNdEx < postIndex { var v int32 @@ -4082,8 +4405,10 @@ func (m *NinRepPackedNativeUnsafe) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field11) == 0 { - m.Field11 = make([]uint64, 0, packedLen/8) + var elementCount int + elementCount = packedLen / 8 + if elementCount != 0 && len(m.Field11) == 0 { + m.Field11 = make([]uint64, 0, elementCount) } for iNdEx < postIndex { var v uint64 @@ -4129,8 +4454,10 @@ func (m *NinRepPackedNativeUnsafe) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field12) == 0 { - m.Field12 = make([]int64, 0, packedLen/8) + var elementCount int + elementCount = packedLen / 8 + if elementCount != 0 && len(m.Field12) == 0 { + m.Field12 = make([]int64, 0, elementCount) } for iNdEx < postIndex { var v int64 @@ -4185,6 +4512,11 @@ func (m *NinRepPackedNativeUnsafe) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + elementCount = packedLen + if elementCount != 0 && len(m.Field13) == 0 { + m.Field13 = make([]bool, 0, elementCount) + } for iNdEx < postIndex { var v int for shift := uint(0); ; shift += 7 { diff --git a/test/packed/packed_test.go b/test/packed/packed_test.go index aed365db2c..0720d627de 100644 --- a/test/packed/packed_test.go +++ b/test/packed/packed_test.go @@ -39,6 +39,113 @@ import ( "unsafe" ) +func BenchmarkVarintIssue436withCount(b *testing.B) { + var arraySizes = []struct { + name string + value int64 + }{ + {"2^0_ints", 1 << 0}, + {"2^1_ints", 1 << 1}, + {"2^2_ints", 1 << 2}, + {"2^3_ints", 1 << 3}, + {"2^4_ints", 1 << 4}, + {"2^8_ints", 1 << 8}, + {"2^16_ints", 1 << 16}, + {"2^20_ints", 1 << 20}, + {"2^24_ints", 1 << 24}, + } + + var varintSizes = []struct { + name string + value int64 + }{ + {"max_int 2^7-4", 1<<7 - 4}, + {"max_int 2^15-4", 1<<15 - 4}, + {"max_int 2^31-4", 1<<31 - 4}, + {"max_int 2^63-4", 1<<63 - 4}, + } + + for _, arraySize := range arraySizes { + for _, varintSize := range varintSizes { + seed := time.Now().UnixNano() + rng := math_rand.New(math_rand.NewSource(seed)) + buf := make([]int64, arraySize.value) + for j := range buf { + buf[j] = rng.Int63n(varintSize.value) + } + + b.Run(arraySize.name+", "+varintSize.name, func(b *testing.B) { + msg := &NinRepNative{ + Field8: buf, + } + + data, err := proto.Marshal(msg) + if err != nil { + b.Fatal(err) + } + + normalmsg := &NinRepNative{} + + for i := 0; i < b.N; i++ { + err = proto.Unmarshal(data, normalmsg) + if err != nil { + b.Fatal(err) + } + } + }) + } + } +} + +func TestVarintIssue436(t *testing.T) { + n := 1 << 22 // Makes for 32 MiB + + m := &runtime.MemStats{} + + msgNormal := &NinRepNative{ + Field8: make([]int64, n), + } + dataNormal, err := proto.Marshal(msgNormal) + if err != nil { + t.Fatal(err) + } + + normalmsg := &NinRepNative{} + runtime.ReadMemStats(m) + beforeNormal := m.TotalAlloc + err = proto.Unmarshal(dataNormal, normalmsg) + runtime.ReadMemStats(m) + afterNormal := m.TotalAlloc + if err != nil { + t.Fatal(err) + } + + msgPacked := &NinRepPackedNative{ + Field8: make([]int64, n), + } + dataPacked, err := proto.Marshal(msgPacked) + if err != nil { + t.Fatal(err) + } + + packedmsg := &NinRepPackedNative{} + runtime.ReadMemStats(m) + beforePacked := m.TotalAlloc + err = proto.Unmarshal(dataPacked, packedmsg) + runtime.ReadMemStats(m) + afterPacked := m.TotalAlloc + if err != nil { + t.Fatal(err) + } + + totalNormal := afterNormal - beforeNormal + totalPacked := afterPacked - beforePacked + usedRatio := float64(totalPacked) / float64(totalNormal) + if usedRatio > 0.5 { + t.Fatalf("unmarshaling packed msg allocated too much memory:\nnormal:\t\t%d bytes\npacked:\t\t%d bytes\nused ratio:\t%.2f%%", totalNormal, totalPacked, usedRatio*100) + } +} + func TestIssue436(t *testing.T) { n := 1 << 22 // Makes for 32 MiB diff --git a/test/theproto3/combos/both/theproto3.pb.go b/test/theproto3/combos/both/theproto3.pb.go index a33a2d3feb..33f6033fd7 100644 --- a/test/theproto3/combos/both/theproto3.pb.go +++ b/test/theproto3/combos/both/theproto3.pb.go @@ -6619,6 +6619,17 @@ func (m *Message) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Key) == 0 { + m.Key = make([]uint64, 0, elementCount) + } for iNdEx < postIndex { var v uint64 for shift := uint(0); ; shift += 7 { @@ -11348,6 +11359,17 @@ func (m *NotPacked) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Key) == 0 { + m.Key = make([]uint64, 0, elementCount) + } for iNdEx < postIndex { var v uint64 for shift := uint(0); ; shift += 7 { diff --git a/test/theproto3/combos/unmarshaler/theproto3.pb.go b/test/theproto3/combos/unmarshaler/theproto3.pb.go index fdc6d887a7..b19df3a370 100644 --- a/test/theproto3/combos/unmarshaler/theproto3.pb.go +++ b/test/theproto3/combos/unmarshaler/theproto3.pb.go @@ -5410,6 +5410,17 @@ func (m *Message) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Key) == 0 { + m.Key = make([]uint64, 0, elementCount) + } for iNdEx < postIndex { var v uint64 for shift := uint(0); ; shift += 7 { @@ -10089,6 +10100,17 @@ func (m *NotPacked) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Key) == 0 { + m.Key = make([]uint64, 0, elementCount) + } for iNdEx < postIndex { var v uint64 for shift := uint(0); ; shift += 7 { diff --git a/test/unrecognized/unrecognized.pb.go b/test/unrecognized/unrecognized.pb.go index a3437a6661..07620ee6f4 100644 --- a/test/unrecognized/unrecognized.pb.go +++ b/test/unrecognized/unrecognized.pb.go @@ -3561,8 +3561,10 @@ func (m *C) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field7) == 0 { - m.Field7 = make([]float32, 0, packedLen/4) + var elementCount int + elementCount = packedLen / 4 + if elementCount != 0 && len(m.Field7) == 0 { + m.Field7 = make([]float32, 0, elementCount) } for iNdEx < postIndex { var v uint32 @@ -3661,8 +3663,10 @@ func (m *U) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field2) == 0 { - m.Field2 = make([]float64, 0, packedLen/8) + var elementCount int + elementCount = packedLen / 8 + if elementCount != 0 && len(m.Field2) == 0 { + m.Field2 = make([]float64, 0, elementCount) } for iNdEx < postIndex { var v uint64 @@ -4080,8 +4084,10 @@ func (m *OldC) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field7) == 0 { - m.Field7 = make([]float32, 0, packedLen/4) + var elementCount int + elementCount = packedLen / 4 + if elementCount != 0 && len(m.Field7) == 0 { + m.Field7 = make([]float32, 0, elementCount) } for iNdEx < postIndex { var v uint32 @@ -4210,8 +4216,10 @@ func (m *OldU) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field2) == 0 { - m.Field2 = make([]float64, 0, packedLen/8) + var elementCount int + elementCount = packedLen / 8 + if elementCount != 0 && len(m.Field2) == 0 { + m.Field2 = make([]float64, 0, elementCount) } for iNdEx < postIndex { var v uint64 diff --git a/test/unrecognizedgroup/unrecognizedgroup.pb.go b/test/unrecognizedgroup/unrecognizedgroup.pb.go index 2bcd3a8aba..dd95ee11df 100644 --- a/test/unrecognizedgroup/unrecognizedgroup.pb.go +++ b/test/unrecognizedgroup/unrecognizedgroup.pb.go @@ -1550,8 +1550,10 @@ func (m *NewNoGroup) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if len(m.Field3) == 0 { - m.Field3 = make([]float64, 0, packedLen/8) + var elementCount int + elementCount = packedLen / 8 + if elementCount != 0 && len(m.Field3) == 0 { + m.Field3 = make([]float64, 0, elementCount) } for iNdEx < postIndex { var v uint64