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

Function getArrayOrJSONLength

pkg/util/encoding/encoding.go:1923–1946  ·  view source on GitHub ↗
(
	buf []byte, dir Direction, keyDoneFn func(buf []byte, dir Direction) bool,
)

Source from the content-addressed store, hash-verified

1921}
1922
1923func getArrayOrJSONLength(
1924 buf []byte, dir Direction, keyDoneFn func(buf []byte, dir Direction) bool,
1925) (int, error) {
1926 result := 0
1927
1928 for {
1929 if len(buf) == 0 {
1930 return 0, errors.AssertionFailedf("invalid encoding (unterminated)")
1931 }
1932 if keyDoneFn(buf, dir) {
1933 // Increment to include the terminator byte.
1934 result++
1935 break
1936 }
1937 next, err := PeekLength(buf)
1938 if err != nil {
1939 return 0, err
1940 }
1941 // Shift buf over by the encoded data amount.
1942 buf = buf[next:]
1943 result += next
1944 }
1945 return result, nil
1946}
1947
1948// peekBox2DLength peeks to look at the length of a box2d encoding.
1949func peekBox2DLength(b []byte) (int, error) {

Callers 1

PeekLengthFunction · 0.85

Calls 1

PeekLengthFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…