MCPcopy Create free account
hub / github.com/antonmedv/gitmal / readBinaryDeltaSize

Function readBinaryDeltaSize

pkg/gitdiff/apply_binary.go:121–131  ·  view source on GitHub ↗

readBinaryDeltaSize reads a variable length size from a delta-encoded binary fragment, returing the size and the unused data. Data is encoded as: [[1xxxxxxx]...] [0xxxxxxx] in little-endian order, with 7 bits of the value per byte.

(d []byte)

Source from the content-addressed store, hash-verified

119//
120// in little-endian order, with 7 bits of the value per byte.
121func readBinaryDeltaSize(d []byte) (size int64, rest []byte) {
122 shift := uint(0)
123 for i, b := range d {
124 size |= int64(b&0x7F) << shift
125 shift += 7
126 if b <= 0x7F {
127 return size, d[i+1:]
128 }
129 }
130 return size, nil
131}
132
133// applyBinaryDeltaAdd applies an add opcode in a delta-encoded binary
134// fragment, returning the amount of data written and the usused part of the

Callers 1

applyBinaryDeltaFragmentFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected