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

Method ReadVarint32

go/fory/buffer.go:1279–1286  ·  view source on GitHub ↗

ReadVarint32 reads a signed int32 using zigzag decoding (compatible with Java's readVarint32).

(err *Error)

Source from the content-addressed store, hash-verified

1277
1278// ReadVarint32 reads a signed int32 using zigzag decoding (compatible with Java's readVarint32).
1279func (b *ByteBuffer) ReadVarint32(err *Error) int32 {
1280 u := b.ReadVarUint32(err)
1281 v := int32(u >> 1)
1282 if u&1 != 0 {
1283 v = ^v
1284 }
1285 return v
1286}
1287
1288// UnsafeReadVarint32 reads a varint32 without bounds checking.
1289// Caller must ensure remaining() >= 5 before calling.

Callers 15

TestDecimalWireEncodingFunction · 0.95
testBufferVarFunction · 0.95
ReadDataMethod · 0.45
readNumericValueByTypeIDFunction · 0.45
readI32ToI64ScalarFunction · 0.45
readDirectIntegerScalarFunction · 0.45
ReadRefFlagMethod · 0.45
ReadDataMethod · 0.45
checkVarintFunction · 0.45
checkVarintWriteFunction · 0.45
ReadDataMethod · 0.45

Calls 2

ReadVarUint32Method · 0.95
int32Function · 0.50

Tested by 4

TestDecimalWireEncodingFunction · 0.76
checkVarintFunction · 0.36
checkVarintWriteFunction · 0.36
ReadDataMethod · 0.36