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

Method gMap

gen/unmarshal.go:516–542  ·  view source on GitHub ↗
(m *Map)

Source from the content-addressed store, hash-verified

514}
515
516func (u *unmarshalGen) gMap(m *Map) {
517 if !u.p.ok() {
518 return
519 }
520 sz := randIdent()
521 u.p.declare(sz, u32)
522 u.assignMap(sz, mapHeader, 0)
523
524 // allocate or clear map
525 u.p.resizeMap(sz, m)
526
527 // We likely need a field.
528 // Add now to not be inside for scope.
529 u.needsField()
530
531 // loop and get key,value
532 u.p.printf("\nfor %s > 0 {", sz)
533 u.p.printf("\nvar %s %s; %s--", m.Validx, m.Value.TypeName(), sz)
534 m.readKey(u.ctx, u.p, u, u.assignAndCheck)
535 u.ctx.PushVar(m.Keyidx)
536 m.Value.SetIsAllowNil(false)
537 setTypeParams(m.Value, m.typeParams)
538 next(u, m.Value)
539 u.ctx.Pop()
540 u.p.mapAssign(m)
541 u.p.closeblock()
542}
543
544func (u *unmarshalGen) gPtr(p *Ptr) {
545 u.p.printf("\nif msgp.IsNil(bts) { bts, err = msgp.ReadNilBytes(bts); if err != nil { return }; %s = nil; } else { ", p.Varname())

Callers

nothing calls this directly

Calls 15

assignMapMethod · 0.95
needsFieldMethod · 0.95
randIdentFunction · 0.85
setTypeParamsFunction · 0.85
nextFunction · 0.85
okMethod · 0.80
declareMethod · 0.80
resizeMapMethod · 0.80
printfMethod · 0.80
readKeyMethod · 0.80
PushVarMethod · 0.80
PopMethod · 0.80

Tested by

no test coverage detected