ReadTaggedInt64 reads int64 using tagged encoding. If bit 0 is 0, return value >> 1 (arithmetic shift). Otherwise, skip flag byte and read 8 bytes as int64.
(err *Error)
| 1082 | // If bit 0 is 0, return value >> 1 (arithmetic shift). |
| 1083 | // Otherwise, skip flag byte and read 8 bytes as int64. |
| 1084 | func (b *ByteBuffer) ReadTaggedInt64(err *Error) int64 { |
| 1085 | if b.readerIndex+4 > len(b.data) { |
| 1086 | if !b.fill(4, err) { |
| 1087 | return 0 |
| 1088 | } |
| 1089 | } |
| 1090 | var i int32 |
| 1091 | if isLittleEndian { |
| 1092 | i = *(*int32)(unsafe.Pointer(&b.data[b.readerIndex])) |
| 1093 | } else { |
| 1094 | i = int32(binary.LittleEndian.Uint32(b.data[b.readerIndex:])) |
| 1095 | } |
| 1096 | if (i & 0b1) != 0b1 { |
| 1097 | b.readerIndex += 4 |
| 1098 | return int64(i >> 1) // arithmetic right shift |
| 1099 | } |
| 1100 | if b.readerIndex+9 > len(b.data) { |
| 1101 | if !b.fill(9, err) { |
| 1102 | return 0 |
| 1103 | } |
| 1104 | } |
| 1105 | var value int64 |
| 1106 | if isLittleEndian { |
| 1107 | value = *(*int64)(unsafe.Pointer(&b.data[b.readerIndex+1])) |
| 1108 | } else { |
| 1109 | value = int64(binary.LittleEndian.Uint64(b.data[b.readerIndex+1:])) |
| 1110 | } |
| 1111 | b.readerIndex += 9 |
| 1112 | return value |
| 1113 | } |
| 1114 | |
| 1115 | // WriteTaggedUint64 writes uint64 using tagged encoding. |
| 1116 | // If value is in [0, 0x7fffffff], encode as 4 bytes: ((value as u32) << 1). |
no test coverage detected