forked from TrueCloudLab/frostfs-node
[#209] compression: Do not store uncompressible data
Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
parent
529d0bc710
commit
a1b4ba9980
1 changed files with 5 additions and 1 deletions
|
@ -87,7 +87,11 @@ func (c *Config) Compress(data []byte) []byte {
|
|||
return data
|
||||
}
|
||||
maxSize := c.encoder.MaxEncodedSize(len(data))
|
||||
return c.encoder.EncodeAll(data, make([]byte, 0, maxSize))
|
||||
compressed := c.encoder.EncodeAll(data, make([]byte, 0, maxSize))
|
||||
if len(data) < len(compressed) {
|
||||
return data
|
||||
}
|
||||
return compressed
|
||||
}
|
||||
|
||||
// Close closes encoder and decoder, returns any error occurred.
|
||||
|
|
Loading…
Reference in a new issue