MCPcopy Create free account
hub / github.com/apache/fory / ReadTaggedInt64

Method ReadTaggedInt64

go/fory/buffer.go:1084–1113  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

1082// If bit 0 is 0, return value >> 1 (arithmetic shift).
1083// Otherwise, skip flag byte and read 8 bytes as int64.
1084func (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).

Callers 12

ReadDataMethod · 0.45
readNumericValueByTypeIDFunction · 0.45
readDirectIntegerScalarFunction · 0.45
ReadDataMethod · 0.45
readRemainingFieldMethod · 0.45
readOptionFastFunction · 0.45
readFieldsInOrderMethod · 0.45
skipValueFunction · 0.45
readArrayValuesMethod · 0.45
readInt64ListValuesFunction · 0.45

Calls 3

fillMethod · 0.95
int32Function · 0.50
int64Function · 0.50

Tested by

no test coverage detected