()
| 217 | } |
| 218 | |
| 219 | func (d *Decbuf) Varint64() int64 { |
| 220 | if d.E != nil { |
| 221 | return 0 |
| 222 | } |
| 223 | // Decode as unsigned first, since that's what the varint library implements. |
| 224 | ux, n := varint.Uvarint(d.B) |
| 225 | if n < 1 { |
| 226 | d.E = ErrInvalidSize |
| 227 | return 0 |
| 228 | } |
| 229 | // Now decode "ZigZag encoding" https://developers.google.com/protocol-buffers/docs/encoding#signed_integers. |
| 230 | x := int64(ux >> 1) |
| 231 | if ux&1 != 0 { |
| 232 | x = ^x |
| 233 | } |
| 234 | d.B = d.B[n:] |
| 235 | return x |
| 236 | } |
| 237 | |
| 238 | func (d *Decbuf) Uvarint64() uint64 { |
| 239 | if d.E != nil { |
no test coverage detected