( buf []byte, dir Direction, keyDoneFn func(buf []byte, dir Direction) bool, )
| 1921 | } |
| 1922 | |
| 1923 | func 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. |
| 1949 | func peekBox2DLength(b []byte) (int, error) { |
no test coverage detected
searching dependent graphs…