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

Method FastRead

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

Source from the content-addressed store, hash-verified

1691}
1692
1693func (p *ExampleJSONString) FastRead(b []byte) (off int, err error) {
1694 var ftyp thrift.TType
1695 var fid int16
1696 var l int
1697 var isset uint8
1698 x := thrift.BinaryProtocol{}
1699 for {
1700 ftyp, fid, l, err = x.ReadFieldBegin(b[off:])
1701 off += l
1702 if err != nil {
1703 goto ReadFieldBeginError
1704 }
1705 if ftyp == thrift.STOP {
1706 break
1707 }
1708 switch uint32(fid)<<8 | uint32(ftyp) {
1709 case 0x10c: // p.Query ID:1 thrift.STRUCT
1710 p.Query = NewJSONObject()
1711 l, err = p.Query.FastRead(b[off:])
1712 off += l
1713 if err != nil {
1714 goto ReadFieldError
1715 }
1716 case 0x20f: // p.Query2 ID:2 thrift.LIST
1717 var sz int
1718 _, sz, l, err = x.ReadListBegin(b[off:])
1719 off += l
1720 if err != nil {
1721 goto ReadFieldError
1722 }
1723 p.Query2 = make([]string, sz)
1724 for i := 0; i < sz; i++ {
1725 p.Query2[i], l, err = x.ReadString(b[off:])
1726 off += l
1727 if err != nil {
1728 goto ReadFieldError
1729 }
1730 }
1731 isset |= 0x1
1732 case 0x30c: // p.Header ID:3 thrift.STRUCT
1733 p.Header = NewJSONObject()
1734 l, err = p.Header.FastRead(b[off:])
1735 off += l
1736 if err != nil {
1737 goto ReadFieldError
1738 }
1739 isset |= 0x2
1740 case 0x40d: // p.Header2 ID:4 thrift.MAP
1741 var sz int
1742 _, _, sz, l, err = x.ReadMapBegin(b[off:])
1743 off += l
1744 if err != nil {
1745 goto ReadFieldError
1746 }
1747 p.Header2 = make(map[int32]string, sz)
1748 for i := 0; i < sz; i++ {
1749 var k int32
1750 var v string

Callers 1

TestJSONStringFunction · 0.95

Calls 8

ReadFieldBeginMethod · 0.95
ReadListBeginMethod · 0.95
ReadStringMethod · 0.95
ReadMapBeginMethod · 0.95
ReadI32Method · 0.95
SkipMethod · 0.95
NewJSONObjectFunction · 0.85
FastReadMethod · 0.45

Tested by 1

TestJSONStringFunction · 0.76