MCPcopy Create free account
hub / github.com/auxten/postgresql-parser / getVarintLen

Function getVarintLen

pkg/util/encoding/encoding.go:261–279  ·  view source on GitHub ↗

getVarintLen returns the encoded length of an encoded varint. Assumes the slice has at least one byte.

(b []byte)

Source from the content-addressed store, hash-verified

259// getVarintLen returns the encoded length of an encoded varint. Assumes the
260// slice has at least one byte.
261func getVarintLen(b []byte) (int, error) {
262 length := int(b[0]) - intZero
263 if length >= 0 {
264 if length <= intSmall {
265 // just the tag
266 return 1, nil
267 }
268 // tag and length-intSmall bytes
269 length = 1 + length - intSmall
270 } else {
271 // tag and -length bytes
272 length = 1 - length
273 }
274
275 if length > len(b) {
276 return 0, errors.Errorf("varint length %d exceeds slice length %d", length, len(b))
277 }
278 return length, nil
279}
280
281// DecodeVarintAscending decodes a value encoded by EncodeVaringAscending.
282func DecodeVarintAscending(b []byte) ([]byte, int64, error) {

Callers 4

getBitArrayWordsLenFunction · 0.85
GetMultiVarintLenFunction · 0.85
PeekLengthFunction · 0.85
getDecimalLenFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…