AppendBytes appends bytes to the slice as MessagePack 'bin' data
(b []byte, bts []byte)
| 191 | |
| 192 | // AppendBytes appends bytes to the slice as MessagePack 'bin' data |
| 193 | func AppendBytes(b []byte, bts []byte) []byte { |
| 194 | sz := len(bts) |
| 195 | var o []byte |
| 196 | var n int |
| 197 | switch { |
| 198 | case sz <= math.MaxUint8: |
| 199 | o, n = ensure(b, 2+sz) |
| 200 | prefixu8(o[n:], mbin8, uint8(sz)) |
| 201 | n += 2 |
| 202 | case sz <= math.MaxUint16: |
| 203 | o, n = ensure(b, 3+sz) |
| 204 | prefixu16(o[n:], mbin16, uint16(sz)) |
| 205 | n += 3 |
| 206 | default: |
| 207 | o, n = ensure(b, 5+sz) |
| 208 | prefixu32(o[n:], mbin32, uint32(sz)) |
| 209 | n += 5 |
| 210 | } |
| 211 | return o[:n+copy(o[n:], bts)] |
| 212 | } |
| 213 | |
| 214 | // AppendBytesHeader appends an 'bin' header with |
| 215 | // the given size to the slice. |
searching dependent graphs…