EncodeCompactBytes joins bytes with its length into a byte slice. It is more efficient in both space and time compare to EncodeBytes. Note that the encoded result is not memcomparable.
(b []byte, data []byte)
| 162 | // efficient in both space and time compare to EncodeBytes. Note that the encoded |
| 163 | // result is not memcomparable. |
| 164 | func EncodeCompactBytes(b []byte, data []byte) []byte { |
| 165 | b = reallocBytes(b, binary.MaxVarintLen64+len(data)) |
| 166 | b = EncodeVarint(b, int64(len(data))) |
| 167 | return append(b, data...) |
| 168 | } |
| 169 | |
| 170 | // DecodeCompactBytes decodes bytes which is encoded by EncodeCompactBytes before. |
| 171 | func DecodeCompactBytes(b []byte) ([]byte, []byte, error) { |
searching dependent graphs…