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

Function getBytesLength

pkg/util/encoding/encoding.go:847–863  ·  view source on GitHub ↗

getBytesLength finds the length of a bytes encoding.

(b []byte, e escapes)

Source from the content-addressed store, hash-verified

845
846// getBytesLength finds the length of a bytes encoding.
847func getBytesLength(b []byte, e escapes) (int, error) {
848 // Skip the tag.
849 skipped := 1
850 for {
851 i := bytes.IndexByte(b[skipped:], e.escape)
852 if i == -1 {
853 return 0, errors.Errorf("did not find terminator %#x in buffer %#x", e.escape, b)
854 }
855 if i+1 >= len(b) {
856 return 0, errors.Errorf("malformed escape in buffer %#x", b)
857 }
858 skipped += i + escapeLength
859 if b[skipped-1] == e.escapedTerm {
860 return skipped, nil
861 }
862 }
863}
864
865// prettyPrintInvertedIndexKey returns a string representation of the path part of a JSON inverted
866// index.

Callers 1

PeekLengthFunction · 0.85

Calls 1

ErrorfMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…