Skip to content
This repository has been archived by the owner on Jan 11, 2021. It is now read-only.

Commit

Permalink
address comment
Browse files Browse the repository at this point in the history
  • Loading branch information
sunchao committed May 1, 2018
1 parent df990ca commit 26136e9
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/compression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,9 @@ impl ZSTDCodec {
}
}

/// Compression level (1-21) for ZSTD. Choose 1 here for better compression speed.
const ZSTD_COMPRESSION_LEVEL: i32 = 1;

impl Codec for ZSTDCodec {
fn decompress(&mut self, input_buf: &[u8], output_buf: &mut Vec<u8>) -> Result<usize> {
let mut decoder = zstd::Decoder::new(input_buf)?;
Expand All @@ -241,7 +244,7 @@ impl Codec for ZSTDCodec {

fn compress(&mut self, input_buf: &[u8]) -> Result<Vec<u8>> {
let output = Vec::new();
let mut encoder = zstd::Encoder::new(output, 1)?;
let mut encoder = zstd::Encoder::new(output, ZSTD_COMPRESSION_LEVEL)?;
encoder.write_all(&input_buf[..])?;
encoder.finish()
.map_err(|e| general_err!("Error when compressing using ZSTD: {}", e))
Expand Down

0 comments on commit 26136e9

Please sign in to comment.