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

Method gMap

gen/encode.go:279–316  ·  view source on GitHub ↗
(m *Map)

Source from the content-addressed store, hash-verified

277}
278
279func (e *encodeGen) gMap(m *Map) {
280 if !e.p.ok() {
281 return
282 }
283 e.fuseHook()
284 vname := m.Varname()
285 e.writeAndCheckWithMapLimit(mapHeader, lenAsUint32, vname)
286
287 e.p.printf("\nfor %s, %s := range %s {", m.Keyidx, m.Validx, vname)
288 if m.Key != nil {
289 if m.AllowBinMaps {
290 e.ctx.PushVar(m.Keyidx)
291 m.Key.SetVarname(m.Keyidx)
292 next(e, m.Key)
293 e.ctx.Pop()
294 } else {
295 keyIdx := m.Keyidx
296 if key, ok := m.Key.(*BaseElem); ok {
297 if m.AutoMapShims && CanAutoShim[key.Value] {
298 keyIdx = fmt.Sprintf("msgp.AutoShim{}.%sString(%s(%s))", key.Value.String(), strings.ToLower(key.Value.String()), keyIdx)
299 } else if key.Value == String {
300 keyIdx = fmt.Sprintf("%s(%s)", key.ToBase(), keyIdx)
301 } else if key.alias != "" {
302 keyIdx = fmt.Sprintf("string(%s)", keyIdx)
303 }
304 }
305 e.writeAndCheck(stringTyp, literalFmt, keyIdx)
306 }
307 } else {
308 e.writeAndCheck(stringTyp, literalFmt, m.Keyidx)
309 }
310 e.ctx.PushVar(m.Keyidx)
311 m.Value.SetIsAllowNil(false)
312 setTypeParams(m.Value, m.typeParams)
313 next(e, m.Value)
314 e.ctx.Pop()
315 e.p.closeblock()
316}
317
318func (e *encodeGen) gPtr(s *Ptr) {
319 if !e.p.ok() {

Callers

nothing calls this directly

Calls 15

fuseHookMethod · 0.95
writeAndCheckMethod · 0.95
nextFunction · 0.85
setTypeParamsFunction · 0.85
okMethod · 0.80
printfMethod · 0.80
PushVarMethod · 0.80
PopMethod · 0.80
ToBaseMethod · 0.80
closeblockMethod · 0.80
VarnameMethod · 0.65

Tested by

no test coverage detected