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

Method FastRead

testdata/kitex_gen/example3/k-example3.go:3054–3108  ·  view source on GitHub ↗
(b []byte)

Source from the content-addressed store, hash-verified

3052}
3053
3054func (p *ExampleDefaultValue) FastRead(b []byte) (off int, err error) {
3055 var ftyp thrift.TType
3056 var fid int16
3057 var l int
3058 x := thrift.BinaryProtocol{}
3059 for {
3060 ftyp, fid, l, err = x.ReadFieldBegin(b[off:])
3061 off += l
3062 if err != nil {
3063 goto ReadFieldBeginError
3064 }
3065 if ftyp == thrift.STOP {
3066 break
3067 }
3068 switch uint32(fid)<<8 | uint32(ftyp) {
3069 case 0x10b: // p.A ID:1 thrift.STRING
3070 p.A, l, err = x.ReadString(b[off:])
3071 off += l
3072 if err != nil {
3073 goto ReadFieldError
3074 }
3075 case 0x208: // p.B ID:2 thrift.I32
3076 p.B, l, err = x.ReadI32(b[off:])
3077 off += l
3078 if err != nil {
3079 goto ReadFieldError
3080 }
3081 case 0x304: // p.C ID:3 thrift.DOUBLE
3082 p.C, l, err = x.ReadDouble(b[off:])
3083 off += l
3084 if err != nil {
3085 goto ReadFieldError
3086 }
3087 case 0x40b: // p.D ID:4 thrift.STRING
3088 p.D, l, err = x.ReadString(b[off:])
3089 off += l
3090 if err != nil {
3091 goto ReadFieldError
3092 }
3093 default:
3094 l, err = x.Skip(b[off:], ftyp)
3095 off += l
3096 if err != nil {
3097 goto SkipFieldError
3098 }
3099 }
3100 }
3101 return
3102ReadFieldBeginError:
3103 return off, thrift.PrependError(fmt.Sprintf("%T read field begin error: ", p), err)
3104ReadFieldError:
3105 return off, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fid, fieldIDToName_ExampleDefaultValue[fid]), err)
3106SkipFieldError:
3107 return off, thrift.PrependError(fmt.Sprintf("%T skip field %d type %d error: ", p, fid, ftyp), err)
3108}
3109
3110func (p *ExampleOptionalDefaultValue) BLength() int {
3111 if p == nil {

Callers

nothing calls this directly

Calls 5

ReadFieldBeginMethod · 0.95
ReadStringMethod · 0.95
ReadI32Method · 0.95
ReadDoubleMethod · 0.95
SkipMethod · 0.95

Tested by

no test coverage detected