ReadTaggedUint64 reads uint64 using tagged encoding. If bit 0 is 0, return value >> 1. Otherwise, skip flag byte and read 8 bytes as uint64.
(err *Error)
| 1135 | // If bit 0 is 0, return value >> 1. |
| 1136 | // Otherwise, skip flag byte and read 8 bytes as uint64. |
| 1137 | func (b *ByteBuffer) ReadTaggedUint64(err *Error) uint64 { |
| 1138 | if b.readerIndex+4 > len(b.data) { |
| 1139 | if !b.fill(4, err) { |
| 1140 | return 0 |
| 1141 | } |
| 1142 | } |
| 1143 | var i uint32 |
| 1144 | if isLittleEndian { |
| 1145 | i = *(*uint32)(unsafe.Pointer(&b.data[b.readerIndex])) |
| 1146 | } else { |
| 1147 | i = binary.LittleEndian.Uint32(b.data[b.readerIndex:]) |
| 1148 | } |
| 1149 | if (i & 0b1) != 0b1 { |
| 1150 | b.readerIndex += 4 |
| 1151 | return uint64(i >> 1) |
| 1152 | } |
| 1153 | if b.readerIndex+9 > len(b.data) { |
| 1154 | if !b.fill(9, err) { |
| 1155 | return 0 |
| 1156 | } |
| 1157 | } |
| 1158 | var value uint64 |
| 1159 | if isLittleEndian { |
| 1160 | value = *(*uint64)(unsafe.Pointer(&b.data[b.readerIndex+1])) |
| 1161 | } else { |
| 1162 | value = binary.LittleEndian.Uint64(b.data[b.readerIndex+1:]) |
| 1163 | } |
| 1164 | b.readerIndex += 9 |
| 1165 | return value |
| 1166 | } |
| 1167 | |
| 1168 | // ReadVarUint64 reads unsigned varint |
| 1169 | func (b *ByteBuffer) ReadVarUint64(err *Error) uint64 { |
no test coverage detected