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)
| 404 | // EncodeVarintAscending for rationale. The encoded bytes are appended to the |
| 405 | // supplied buffer and the final buffer is returned. |
| 406 | func EncodeUvarintAscending(b []byte, v uint64) []byte { |
| 407 | switch { |
| 408 | case v <= intSmall: |
| 409 | return append(b, intZero+byte(v)) |
| 410 | case v <= 0xff: |
| 411 | return append(b, IntMax-7, byte(v)) |
| 412 | case v <= 0xffff: |
| 413 | return append(b, IntMax-6, byte(v>>8), byte(v)) |
| 414 | case v <= 0xffffff: |
| 415 | return append(b, IntMax-5, byte(v>>16), byte(v>>8), byte(v)) |
| 416 | case v <= 0xffffffff: |
| 417 | return append(b, IntMax-4, byte(v>>24), byte(v>>16), byte(v>>8), byte(v)) |
| 418 | case v <= 0xffffffffff: |
| 419 | return append(b, IntMax-3, byte(v>>32), byte(v>>24), byte(v>>16), byte(v>>8), |
| 420 | byte(v)) |
| 421 | case v <= 0xffffffffffff: |
| 422 | return append(b, IntMax-2, byte(v>>40), byte(v>>32), byte(v>>24), byte(v>>16), |
| 423 | byte(v>>8), byte(v)) |
| 424 | case v <= 0xffffffffffffff: |
| 425 | return append(b, IntMax-1, byte(v>>48), byte(v>>40), byte(v>>32), byte(v>>24), |
| 426 | byte(v>>16), byte(v>>8), byte(v)) |
| 427 | default: |
| 428 | return append(b, IntMax, byte(v>>56), byte(v>>48), byte(v>>40), byte(v>>32), |
| 429 | byte(v>>24), byte(v>>16), byte(v>>8), byte(v)) |
| 430 | } |
| 431 | } |
| 432 | |
| 433 | // EncodedLengthUvarintAscending returns the length of the variable length |
| 434 | // representation, i.e. the number of bytes appended by EncodeUvarintAscending. |
no outgoing calls
no test coverage detected
searching dependent graphs…