MCPcopy Create free account
hub / github.com/buger/jsonparser / CodecEncodeSelf

Method CodecEncodeSelf

benchmark/benchmark_codecgen.go:1542–1634  ·  view source on GitHub ↗

Benchmark harness support for STK-REQ-004.

(e *codec1978.Encoder)

Source from the content-addressed store, hash-verified

1540
1541// Benchmark harness support for STK-REQ-004.
1542func (x *MediumPayload) CodecEncodeSelf(e *codec1978.Encoder) {
1543 var h codecSelfer6617
1544 z, r := codec1978.GenHelperEncoder(e)
1545 _, _, _ = h, z, r
1546 if x == nil {
1547 r.EncodeNil()
1548 } else {
1549 if false {
1550 } else if yyxt1 := z.Extension(z.I2Rtid(x)); yyxt1 != nil {
1551 z.EncExtension(x, yyxt1)
1552 } else if !z.EncBinary() && z.IsJSONHandle() {
1553 z.EncJSONMarshal(x)
1554 } else {
1555 yysep2 := !z.EncBinary()
1556 yy2arr2 := z.EncBasicHandle().StructToArray
1557 _, _ = yysep2, yy2arr2
1558 const yyr2 bool = false // struct tag has 'toArray'
1559 if yyr2 || yy2arr2 {
1560 r.WriteArrayStart(2)
1561 } else {
1562 r.WriteMapStart(2)
1563 }
1564 var yyn3 bool
1565 if x.Person == nil {
1566 yyn3 = true
1567 goto LABEL3
1568 }
1569 LABEL3:
1570 if yyr2 || yy2arr2 {
1571 if yyn3 {
1572 r.WriteArrayElem()
1573 r.EncodeNil()
1574 } else {
1575 r.WriteArrayElem()
1576 if x.Person == nil {
1577 r.EncodeNil()
1578 } else {
1579 x.Person.CodecEncodeSelf(e)
1580 }
1581 }
1582 } else {
1583 r.WriteMapElemKey()
1584 if z.IsJSONHandle() {
1585 z.WriteStr("\"Person\"")
1586 } else {
1587 r.EncodeStringEnc(codecSelferCcUTF86617, `Person`)
1588 }
1589 r.WriteMapElemValue()
1590 if yyn3 {
1591 r.EncodeNil()
1592 } else {
1593 if x.Person == nil {
1594 r.EncodeNil()
1595 } else {
1596 x.Person.CodecEncodeSelf(e)
1597 }
1598 }
1599 }

Callers

nothing calls this directly

Calls 1

CodecEncodeSelfMethod · 0.45

Tested by

no test coverage detected