resizeSliceNoNil will resize a slice and will not allow nil slices.
(size string, s *Slice)
| 468 | |
| 469 | // resizeSliceNoNil will resize a slice and will not allow nil slices. |
| 470 | func (p *printer) resizeSliceNoNil(size string, s *Slice) { |
| 471 | p.printf("\nif %[1]s != nil && cap(%[1]s) >= int(%[2]s) {", s.Varname(), size) |
| 472 | p.printf("\n%[1]s = (%[1]s)[:%[2]s]", s.Varname(), size) |
| 473 | p.printf("\n} else { %[1]s = make(%[3]s, %[2]s) }", s.Varname(), size, s.TypeName()) |
| 474 | } |
| 475 | |
| 476 | func (p *printer) arrayCheck(want string, got string) { |
| 477 | p.printf("\nif %[1]s != %[2]s { err = msgp.ArrayError{Wanted: %[2]s, Got: %[1]s}; return }", got, want) |