MCPcopy
hub / github.com/syncthing/syncthing / lz4Compress

Function lz4Compress

lib/protocol/protocol.go:1065–1077  ·  view source on GitHub ↗
(src, buf []byte)

Source from the content-addressed store, hash-verified

1063}
1064
1065func lz4Compress(src, buf []byte) (int, error) {
1066 n, err := lz4.CompressBlock(src, buf[4:], nil)
1067 if err != nil {
1068 return -1, err
1069 } else if n == 0 {
1070 return -1, errNotCompressible
1071 }
1072
1073 // The compressed block is prefixed by the size of the uncompressed data.
1074 binary.BigEndian.PutUint32(buf, uint32(len(src)))
1075
1076 return n + 4, nil
1077}
1078
1079func lz4Decompress(src []byte) ([]byte, error) {
1080 if len(src) < 4 {

Callers 3

TestLZ4CompressionFunction · 0.85
TestLZ4CompressionUpdateFunction · 0.85

Calls

no outgoing calls

Tested by 2

TestLZ4CompressionFunction · 0.68
TestLZ4CompressionUpdateFunction · 0.68