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

Method resizeMap

gen/spec.go:391–401  ·  view source on GitHub ↗

does: if m == nil { m = make(type, size) } else if len(m) > 0 { for key := range m { delete(m, key) } }

(size string, m *Map)

Source from the content-addressed store, hash-verified

389// for key := range m { delete(m, key) }
390// }
391func (p *printer) resizeMap(size string, m *Map) {
392 vn := m.Varname()
393 if !p.ok() {
394 return
395 }
396 p.printf("\nif %s == nil {", vn)
397 p.printf("\n%s = make(%s, %s)", vn, m.TypeName(), size)
398 p.printf("\n} else if len(%s) > 0 {", vn)
399 p.clearMap(vn)
400 p.closeblock()
401}
402
403// CanAutoShim contains the primitives that can be auto-shimmed.
404var CanAutoShim = map[Primitive]bool{Uint: true, Uint8: true, Uint16: true, Uint32: true, Uint64: true, Int: true, Int8: true, Int16: true, Int32: true, Int64: true, Bool: true, Float32: true, Float64: true, Byte: true}

Callers 2

gMapMethod · 0.80
gMapMethod · 0.80

Calls 6

okMethod · 0.95
printfMethod · 0.95
clearMapMethod · 0.95
closeblockMethod · 0.95
VarnameMethod · 0.65
TypeNameMethod · 0.65

Tested by

no test coverage detected