github.com/pyroscope-io/pyroscope@v0.37.3-0.20230725203016-5f6947968bd0/pkg/convert/pprof/streaming/vt_line.go (about)

     1  package streaming
     2  
     3  import (
     4  	"fmt"
     5  	"io"
     6  )
     7  
     8  // revive:disable-next-line:cognitive-complexity,cyclomatic necessary complexity
     9  func (m *line) UnmarshalVT(dAtA []byte) error {
    10  	m.functionID = 0
    11  	m.line = 0
    12  	l := len(dAtA)
    13  	iNdEx := 0
    14  	for iNdEx < l {
    15  		//preIndex := iNdEx
    16  		var wire uint64
    17  		for shift := uint(0); ; shift += 7 {
    18  			if shift >= 64 {
    19  				return ErrIntOverflow
    20  			}
    21  			if iNdEx >= l {
    22  				return io.ErrUnexpectedEOF
    23  			}
    24  			b := dAtA[iNdEx]
    25  			iNdEx++
    26  			wire |= uint64(b&0x7F) << shift
    27  			if b < 0x80 {
    28  				break
    29  			}
    30  		}
    31  		fieldNum := int32(wire >> 3)
    32  		wireType := int(wire & 0x7)
    33  		if wireType == 4 {
    34  			return fmt.Errorf("proto: Line: wiretype end group for non-group")
    35  		}
    36  		if fieldNum <= 0 {
    37  			return fmt.Errorf("proto: Line: illegal tag %d (wire type %d)", fieldNum, wire)
    38  		}
    39  		switch fieldNum {
    40  		case 1:
    41  			if wireType != 0 {
    42  				return fmt.Errorf("proto: wrong wireType = %d for field FunctionId", wireType)
    43  			}
    44  			m.functionID = 0
    45  			for shift := uint(0); ; shift += 7 {
    46  				if shift >= 64 {
    47  					return ErrIntOverflow
    48  				}
    49  				if iNdEx >= l {
    50  					return io.ErrUnexpectedEOF
    51  				}
    52  				b := dAtA[iNdEx]
    53  				iNdEx++
    54  				m.functionID |= uint64(b&0x7F) << shift
    55  				if b < 0x80 {
    56  					break
    57  				}
    58  			}
    59  		case 2:
    60  			if wireType != 0 {
    61  				return fmt.Errorf("proto: wrong wireType = %d for field Line", wireType)
    62  			}
    63  			iline := int64(0)
    64  			for shift := uint(0); ; shift += 7 {
    65  				if shift >= 64 {
    66  					return ErrIntOverflow
    67  				}
    68  				if iNdEx >= l {
    69  					return io.ErrUnexpectedEOF
    70  				}
    71  				b := dAtA[iNdEx]
    72  				iNdEx++
    73  				iline |= int64(b&0x7F) << shift
    74  				if b < 0x80 {
    75  					break
    76  				}
    77  			}
    78  			m.line = iline
    79  		default:
    80  			return ErrUnknownField
    81  		}
    82  	}
    83  
    84  	if iNdEx > l {
    85  		return io.ErrUnexpectedEOF
    86  	}
    87  	return nil
    88  }