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

Method gStruct

gen/size.go:105–133  ·  view source on GitHub ↗
(st *Struct)

Source from the content-addressed store, hash-verified

103}
104
105func (s *sizeGen) gStruct(st *Struct) {
106 if !s.p.ok() {
107 return
108 }
109
110 nfields := uint32(len(st.Fields))
111
112 if st.AsTuple {
113 data := msgp.AppendArrayHeader(nil, nfields)
114 s.addConstant(strconv.Itoa(len(data)))
115 for i := range st.Fields {
116 if !s.p.ok() {
117 return
118 }
119 setTypeParams(st.Fields[i].FieldElem, st.typeParams)
120 next(s, st.Fields[i].FieldElem)
121 }
122 } else {
123 data := msgp.AppendMapHeader(nil, nfields)
124 s.addConstant(strconv.Itoa(len(data)))
125 for i := range st.Fields {
126 data = data[:0]
127 data = msgp.AppendString(data, st.Fields[i].FieldTag)
128 s.addConstant(strconv.Itoa(len(data)))
129 setTypeParams(st.Fields[i].FieldElem, st.typeParams)
130 next(s, st.Fields[i].FieldElem)
131 }
132 }
133}
134
135func (s *sizeGen) gPtr(p *Ptr) {
136 s.state = add // inner must use add

Callers

nothing calls this directly

Calls 7

addConstantMethod · 0.95
AppendArrayHeaderFunction · 0.92
AppendMapHeaderFunction · 0.92
AppendStringFunction · 0.92
setTypeParamsFunction · 0.85
nextFunction · 0.85
okMethod · 0.80

Tested by

no test coverage detected