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

Function BytesNext

pkg/util/encoding/encoding.go:3771–3784  ·  view source on GitHub ↗

BytesNext returns the next possible byte slice, using the extra capacity of the provided slice if possible, and if not, appending an \x00.

(b []byte)

Source from the content-addressed store, hash-verified

3769// BytesNext returns the next possible byte slice, using the extra capacity
3770// of the provided slice if possible, and if not, appending an \x00.
3771func BytesNext(b []byte) []byte {
3772 if cap(b) > len(b) {
3773 bNext := b[:len(b)+1]
3774 if bNext[len(bNext)-1] == 0 {
3775 return bNext
3776 }
3777 }
3778 // TODO(spencer): Do we need to enforce KeyMaxLength here?
3779 // Switched to "make and copy" pattern in #4963 for performance.
3780 bn := make([]byte, len(b)+1)
3781 copy(bn, b)
3782 bn[len(bn)-1] = 0
3783 return bn
3784}
3785
3786// BytesPrevish returns a previous byte slice in lexicographical ordering. It is
3787// impossible in general to find the exact previous byte slice, because it has

Callers 2

NextMethod · 0.92
NextMethod · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…