AppendBytesHeader appends an 'bin' header with the given size to the slice.
(b []byte, sz uint32)
| 214 | // AppendBytesHeader appends an 'bin' header with |
| 215 | // the given size to the slice. |
| 216 | func AppendBytesHeader(b []byte, sz uint32) []byte { |
| 217 | var o []byte |
| 218 | var n int |
| 219 | switch { |
| 220 | case sz <= math.MaxUint8: |
| 221 | o, n = ensure(b, 2) |
| 222 | prefixu8(o[n:], mbin8, uint8(sz)) |
| 223 | return o |
| 224 | case sz <= math.MaxUint16: |
| 225 | o, n = ensure(b, 3) |
| 226 | prefixu16(o[n:], mbin16, uint16(sz)) |
| 227 | return o |
| 228 | } |
| 229 | o, n = ensure(b, 5) |
| 230 | prefixu32(o[n:], mbin32, sz) |
| 231 | return o |
| 232 | } |
| 233 | |
| 234 | // AppendBool appends a bool to the slice |
| 235 | func AppendBool(b []byte, t bool) []byte { |
searching dependent graphs…