mirror of
https://github.com/octoleo/syncthing.git
synced 2025-01-22 22:58:25 +00:00
a0fd619df3
* lib/protocol: Require at least 3.125% savings from compression The new lz4 library doesn't need its output buffer to be the maximum size, unlike the old one (which would allocate if it weren't). It can take a buffer that is of a smaller size and will report if compressed data can fit inside the buffer (with a small chance of reporting a false negative). Use that property to our advantage by requiring compressed data to be at most n-n/32 = .96875*n bytes long for n input bytes. * lib/protocol: Remove unused receivers To make DeepSource happy. * lib/protocol: Micro-optimize lz4Compress Only write the length if compression was successful. This is a memory write, so the compiler can't reorder it. Only check the return value of lz4.CompressBlock. Length-zero inputs are always expanded by LZ4 compression (the library documents this), so the check on len(src) isn't needed.