MCPcopy
hub / github.com/tinylib/msgp / tuple

Method tuple

gen/encode.go:134–160  ·  view source on GitHub ↗
(s *Struct)

Source from the content-addressed store, hash-verified

132}
133
134func (e *encodeGen) tuple(s *Struct) {
135 nfields := len(s.Fields)
136 data := msgp.AppendArrayHeader(nil, uint32(nfields))
137 e.p.printf("\n// array header, size %d", nfields)
138 e.Fuse(data)
139 e.fuseHook()
140 for i := range s.Fields {
141 if !e.p.ok() {
142 return
143 }
144 fieldElem := s.Fields[i].FieldElem
145 anField := s.Fields[i].HasTagPart("allownil") && fieldElem.AllowNil()
146 if anField {
147 e.p.printf("\nif %s { // allownil: if nil", fieldElem.IfZeroExpr())
148 e.p.printf("\nerr = en.WriteNil(); if err != nil { return; }")
149 e.p.printf("\n} else {")
150 }
151 SetIsAllowNil(fieldElem, anField)
152 e.ctx.PushString(s.Fields[i].FieldName)
153 setTypeParams(s.Fields[i].FieldElem, s.typeParams)
154 next(e, s.Fields[i].FieldElem)
155 e.ctx.Pop()
156 if anField {
157 e.p.print("\n}") // close if statement
158 }
159 }
160}
161
162func (e *encodeGen) appendraw(bts []byte) {
163 e.p.print("\nerr = en.Append(")

Callers 1

gStructMethod · 0.95

Calls 14

FuseMethod · 0.95
fuseHookMethod · 0.95
AppendArrayHeaderFunction · 0.92
SetIsAllowNilFunction · 0.85
setTypeParamsFunction · 0.85
nextFunction · 0.85
printfMethod · 0.80
okMethod · 0.80
HasTagPartMethod · 0.80
PushStringMethod · 0.80
PopMethod · 0.80
printMethod · 0.80

Tested by

no test coverage detected