EncodeUvarintAscending encodes the uint64 value using a variable length (length-prefixed) representation. The length is encoded as a single byte indicating the number of encoded bytes (-8) to follow. See EncodeVarintAscending for rationale. The encoded bytes are appended to the supplied buffer and t
(b []byte, v uint64)
| 323 | // EncodeVarintAscending for rationale. The encoded bytes are appended to the |
| 324 | // supplied buffer and the final buffer is returned. |
| 325 | func EncodeUvarintAscending(b []byte, v uint64) []byte { |
| 326 | switch { |
| 327 | case v <= intSmall: |
| 328 | return append(b, intZero+byte(v)) |
| 329 | case v <= 0xff: |
| 330 | return append(b, IntMax-7, byte(v)) |
| 331 | case v <= 0xffff: |
| 332 | return append(b, IntMax-6, byte(v>>8), byte(v)) |
| 333 | case v <= 0xffffff: |
| 334 | return append(b, IntMax-5, byte(v>>16), byte(v>>8), byte(v)) |
| 335 | case v <= 0xffffffff: |
| 336 | return append(b, IntMax-4, byte(v>>24), byte(v>>16), byte(v>>8), byte(v)) |
| 337 | case v <= 0xffffffffff: |
| 338 | return append(b, IntMax-3, byte(v>>32), byte(v>>24), byte(v>>16), byte(v>>8), |
| 339 | byte(v)) |
| 340 | case v <= 0xffffffffffff: |
| 341 | return append(b, IntMax-2, byte(v>>40), byte(v>>32), byte(v>>24), byte(v>>16), |
| 342 | byte(v>>8), byte(v)) |
| 343 | case v <= 0xffffffffffffff: |
| 344 | return append(b, IntMax-1, byte(v>>48), byte(v>>40), byte(v>>32), byte(v>>24), |
| 345 | byte(v>>16), byte(v>>8), byte(v)) |
| 346 | default: |
| 347 | return append(b, IntMax, byte(v>>56), byte(v>>48), byte(v>>40), byte(v>>32), |
| 348 | byte(v>>24), byte(v>>16), byte(v>>8), byte(v)) |
| 349 | } |
| 350 | } |
| 351 | |
| 352 | // EncodeUvarintDescending encodes the uint64 value so that it sorts in |
| 353 | // reverse order, from largest to smallest. |
no outgoing calls
no test coverage detected
searching dependent graphs…