MCPcopy Create free account
hub / github.com/cockroachdb/cockroachdb-parser / peekBox2DLength

Function peekBox2DLength

pkg/util/encoding/encoding.go:1949–1968  ·  view source on GitHub ↗

peekBox2DLength peeks to look at the length of a box2d encoding.

(b []byte)

Source from the content-addressed store, hash-verified

1947
1948// peekBox2DLength peeks to look at the length of a box2d encoding.
1949func peekBox2DLength(b []byte) (int, error) {
1950 length := 0
1951 curr := b
1952 for i := 0; i < 4; i++ {
1953 if len(curr) == 0 {
1954 return 0, errors.Newf("slice too short for box2d")
1955 }
1956 switch curr[0] {
1957 case floatNaN, floatNaNDesc, floatZero:
1958 length++
1959 curr = curr[1:]
1960 case floatNeg, floatPos:
1961 length += 9
1962 curr = curr[9:]
1963 default:
1964 return 0, errors.Newf("unexpected marker for box2d: %x", curr[0])
1965 }
1966 }
1967 return length, nil
1968}
1969
1970// PeekLength returns the length of the encoded value at the start of b. Note:
1971// if this function succeeds, it's not a guarantee that decoding the value will

Callers 2

PeekLengthFunction · 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…