does: if m == nil { m = make(type, size) } else if len(m) > 0 { for key := range m { delete(m, key) } }
(size string, m *Map)
| 389 | // for key := range m { delete(m, key) } |
| 390 | // } |
| 391 | func (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. |
| 404 | var 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} |