AppendArrayHeader appends an array header with the given size to the slice
(b []byte, sz uint32)
| 43 | // AppendArrayHeader appends an array header with |
| 44 | // the given size to the slice |
| 45 | func AppendArrayHeader(b []byte, sz uint32) []byte { |
| 46 | switch { |
| 47 | case sz <= 15: |
| 48 | return append(b, wfixarray(uint8(sz))) |
| 49 | |
| 50 | case sz <= math.MaxUint16: |
| 51 | o, n := ensure(b, 3) |
| 52 | prefixu16(o[n:], marray16, uint16(sz)) |
| 53 | return o |
| 54 | |
| 55 | default: |
| 56 | o, n := ensure(b, 5) |
| 57 | prefixu32(o[n:], marray32, sz) |
| 58 | return o |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | // AppendNil appends a 'nil' byte to the slice |
| 63 | func AppendNil(b []byte) []byte { return append(b, mnil) } |
searching dependent graphs…