MCPcopy Create free account
hub / github.com/cloudwego/dynamicgo / FastRead

Method FastRead

testdata/kitex_gen/example/k-example.go:86–152  ·  view source on GitHub ↗
(b []byte)

Source from the content-addressed store, hash-verified

84}
85
86func (p *ExampleReq) FastRead(b []byte) (off int, err error) {
87 var ftyp thrift.TType
88 var fid int16
89 var l int
90 var isset uint8
91 x := thrift.BinaryProtocol{}
92 for {
93 ftyp, fid, l, err = x.ReadFieldBegin(b[off:])
94 off += l
95 if err != nil {
96 goto ReadFieldBeginError
97 }
98 if ftyp == thrift.STOP {
99 break
100 }
101 switch uint32(fid)<<8 | uint32(ftyp) {
102 case 0x10b: // p.Msg ID:1 thrift.STRING
103 if p.Msg == nil {
104 p.Msg = new(string)
105 }
106 *p.Msg, l, err = x.ReadString(b[off:])
107 off += l
108 if err != nil {
109 goto ReadFieldError
110 }
111 case 0x308: // p.InnerBase ID:3 thrift.I32
112 p.InnerBase, l, err = x.ReadI32(b[off:])
113 off += l
114 if err != nil {
115 goto ReadFieldError
116 }
117 case 0xff0c: // p.Base ID:255 thrift.STRUCT
118 p.Base = base.NewBase()
119 l, err = p.Base.FastRead(b[off:])
120 off += l
121 if err != nil {
122 goto ReadFieldError
123 }
124 isset |= 0x1
125 case 0x7fff04: // p.Subfix ID:32767 thrift.DOUBLE
126 p.Subfix, l, err = x.ReadDouble(b[off:])
127 off += l
128 if err != nil {
129 goto ReadFieldError
130 }
131 default:
132 l, err = x.Skip(b[off:], ftyp)
133 off += l
134 if err != nil {
135 goto SkipFieldError
136 }
137 }
138 }
139 if isset&0x1 == 0 {
140 fid = 255 // Base
141 goto RequiredFieldNotSetError
142 }
143 return

Callers 15

TestChildrenFunction · 0.95
TestTreeGetFunction · 0.95
TestTreeMarshalFunction · 0.95
TestGetFunction · 0.95
TestMarshalToFunction · 0.95
TestSetManyFunction · 0.95
TestStateMachineOOMFunction · 0.95

Calls 7

ReadFieldBeginMethod · 0.95
ReadStringMethod · 0.95
ReadI32Method · 0.95
ReadDoubleMethod · 0.95
SkipMethod · 0.95
NewBaseFunction · 0.92
FastReadMethod · 0.45

Tested by 15

TestChildrenFunction · 0.76
TestTreeGetFunction · 0.76
TestTreeMarshalFunction · 0.76
TestGetFunction · 0.76
TestMarshalToFunction · 0.76
TestSetManyFunction · 0.76
TestStateMachineOOMFunction · 0.76