AppendUint64 appends a uint64 to the slice
(b []byte, u uint64)
| 147 | |
| 148 | // AppendUint64 appends a uint64 to the slice |
| 149 | func AppendUint64(b []byte, u uint64) []byte { |
| 150 | switch { |
| 151 | case u <= (1<<7)-1: |
| 152 | return append(b, wfixint(uint8(u))) |
| 153 | |
| 154 | case u <= math.MaxUint8: |
| 155 | o, n := ensure(b, 2) |
| 156 | putMuint8(o[n:], uint8(u)) |
| 157 | return o |
| 158 | |
| 159 | case u <= math.MaxUint16: |
| 160 | o, n := ensure(b, 3) |
| 161 | putMuint16(o[n:], uint16(u)) |
| 162 | return o |
| 163 | |
| 164 | case u <= math.MaxUint32: |
| 165 | o, n := ensure(b, 5) |
| 166 | putMuint32(o[n:], uint32(u)) |
| 167 | return o |
| 168 | |
| 169 | default: |
| 170 | o, n := ensure(b, 9) |
| 171 | putMuint64(o[n:], u) |
| 172 | return o |
| 173 | |
| 174 | } |
| 175 | } |
| 176 | |
| 177 | // AppendUint appends a uint to the slice |
| 178 | func AppendUint(b []byte, u uint) []byte { return AppendUint64(b, uint64(u)) } |
searching dependent graphs…